Here's the complete code in case anyone else arrives here with the
same problem.

No doubt hardened Rubyists will be able to tidy up my syntax, but this
is passing all my specs right now so I'm happy. :-)

# app/models/project.rb

  acts_as_tree :order => "name"

# app/controllers/projects_controller.rb

  def new
    if params[:parent] == nil
      @parent = 0
    else
      @parent = Project.find(params[:parent]).id
    end
    ...
  end

# app/views/projects/show.html.erb

   <%= link_to("Create A Sub-Project",
{:controller=>"projects", :action=>"new", :parent => @project.id}) %>

# app/views/projects/new.html.erb

  <% form_for(@project) do |f| %>
     ...
     <%= f.hidden_field :parent_id, {:value => @parent} %>
     ...
  <% end %>


On Aug 7, 9:00 am, steven_noble <[email protected]> wrote:
> Sorry:
>
> <%= link_to("Split Project Into Parts",
> {:controller=>"projects", :action=>"new", :parent => @project.id}) %>
>
> On Aug 7, 8:58 am, steven_noble <[email protected]> wrote:
>
> > I understand that's how you retrieve the value from the URL. My
> > question related to how to add the value to the URL first place. As I
> > suspected, the problem was with the syntax of my link_to. I've now
> > solved that problem. For anyone else facing this problem, a working
> > syntax is:
>
> > <%= link_to("Split Project Into Parts",
> > {:action=>"new_project_path", :parent => @project.id}) %>
>
> > On Aug 7, 7:21 am, Marnen Laibow-Koser <rails-mailing-l...@andreas-
>
> > s.net> wrote:
> > > steven_noble wrote:
> > > > Hi Marnen,
>
> > > > Thanks for sticking with me and sorry for not yet getting it.
>
> > > > Am I not doing what you say with the following in projects/show?
>
> > > > <%= link_to 'Create Subproject', new_project_path, :parent =>
> > > > @project.id %>
>
> > > > And should I not be able to retrieve the value in projects/new with
> > > > the following?
>
> > > > <%= debug :parent %>
>
> > > For the third time: params[:parent], not :parent !  :parent is just a
> > > literal symbol.  I already explained this; please reread.
>
> > > Best,
> > > --
> > > Marnen Laibow-Koserhttp://www.marnen.org
> > > [email protected]
>
> > > > s.
>
> > > > On Aug 7, 7:03 am, Marnen Laibow-Koser <rails-mailing-l...@andreas-
>
> > > --
> > > Posted viahttp://www.ruby-forum.com/.
>
>
--~--~---------~--~----~------------~-------~--~----~
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