This code works but looks ugly.
How to merge this two actions?

#verifications/index.haml
- if Ad.unverified_ads.size == 0
- else
  = link_to "Szybka Weryfikacja",
fast_verify_info_verification_path(Ad.unverified_ads.last), :method
=> :put
= link_to "Normal Verify", verify_info_verification_path(ad), :method
=> :put

#verifications/verify_info.haml
= link_to "Verify", verify_verification_path(@ad)
#verifications/fast_verify_info.haml
= link_to "Weryfikuj",
fast_verify_verification_path(Ad.unverified_ads.last), :method => :put
#verification_controller.rb
  def verify_info
    @ad = Ad.find(params[:id])
  end
  def fast_verify_info
    @ad = Ad.find(params[:id])
  end

  def fast_verify
    @ad = Ad.find(params[:id])
    @ad.verify!
    if Ad.unverified_ads.size == 0
      redirect_to verifications_path
    else
    redirect_to
fast_verify_info_verification_path(Ad.unverified_ads.last)
    end
  end
  def verify
    @ad = Ad.find(params[:id])
    @ad.verify!
    if params[:fast] == true
      redirect_to Ad.unverified_ads.last
    else
    redirect_to verifications_path
    end
  end

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to