Forum: Ruby on Rails form for

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
44999b12bbad1b498252b3ac60c3ab0f?d=identicon&s=25 Maulin pa (mpathare)
on 2008-12-15 19:20
I have two models, ladder and statistic
The relationship is
ladder has_many statistics
statistic belongs_to ladder

In a view for my ladder controller action show, I am redirecting the
user to an action in my statistics controller using

<% form for ladder_statistics_path(@ladder) do |f| %>
  <%= submit_tag 'Create' %>
<%end%>

I would think that in the statistics controller the object @ladder and
all of its attributes would be available to me, but only the id is
available in the params hash as params[:ladder_id]

I have to explicitly call

@ladder = ladder.find(params[:ladder_id])

in the statistics controller to get @ladder.name

is this normal, or am I doing something wrong?
Ed437e52d8d6720308720e7e678f3e6d?d=identicon&s=25 Patrick Doyle (Guest)
on 2008-12-15 21:19
(Received via mailing list)
On Mon, Dec 15, 2008 at 1:20 PM, Maulin Pathare <
rails-mailing-list@andreas-s.net> wrote:

>  <%= submit_tag 'Create' %>
> in the statistics controller to get @ladder.name
>
> is this normal, or am I doing something wrong?
>
That's the way I learned it, specifically from
http://akitaonrails.com/2007/12/12/rolling-with-ra...
.

--wpd
This topic is locked and can not be replied to.