How do I pass objects through a _url based on a routing in rails?

Posted by Angela on Stack Overflow See other posts from Stack Overflow or by Angela
Published on 2010-05-27T18:16:22Z Indexed on 2010/05/27 18:21 UTC
Read the original article Hit count: 171

Filed under:
|
|

I want to pass the attributes associated with two objects into a path created from a route. In this case, the _url is skip_contact_letter_url. contact_letter and letter are passed through a render partial. The clip below resides in the partial.

<%= link_to_remote "Skip Letter Remote #{contact_letter}",
        :url => skip_contact_letter_url(contact_letter, letter),
        :update => "update-area-#{contact_letter.id}-#{letter.id}" %>
<span id='update-area-<%="#{contact_letter.id}-#{letter.id}"%>'> </span>

The route I created looks like this:

  map.resources :contact_letters, :member => {:skip => :post} 

And the controller looks like this:

 def skip

    @contact_letter = ContactLetter.new(params[:all])

    @contact_letter.status = "skipped"
    @contact_letter.date_sent = Date.today
    #@contact_letter.date_created = Date.today

    if @contact_letter.save
      render :text => 'This letter was skipped!'

    end   end

When I look at the console, none of the parameters from contact_letter or letter get passed through.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about routing