[Rails] Re: After creating an instance of an object, Rails redirects to the index of the object that it :belongs to

2009-09-12 Thread steven_noble
And with fresh morning eyes, I solved that too. (T'was another concept where it should have been part -- another victim of copy-pasting controller code.) s. On Sep 13, 7:22 am, steven_noble wrote: > I'm an idiot. Perils of copy-pasting controllers and then starting at > th

[Rails] Re: After creating an instance of an object, Rails redirects to the index of the object that it :belongs to

2009-09-12 Thread steven_noble
oject validations and complains about there being no project name, etc. Colin, the submit code is: submit_tag 'Save', :name => 'save' On Sep 13, 12:10 am, Colin Law wrote: > 2009/9/12 steven_noble : > > > > > > > When I click the Save in /views/par

[Rails] After creating an instance of an object, Rails redirects to the index of the object that it :belongs to

2009-09-12 Thread steven_noble
When I click the Save in /views/parts/new.html, I expect to end up on / views/parts/show.html, but instead I end up in /views/projects/ index.html, with the wrong [flash] message. I have: /models/project.rb has_many :parts /mo

[Rails] Re: Traversing nested ActiveRecord associations

2009-09-09 Thread steven_noble
OK, I added a town_id to each house and it's working fine, but if there's a method I've missed that handles this automagically, it'd be great to know. s. On Sep 8, 10:21 pm, steven_noble wrote: > Let's say... > > class Town < ActiveRecord::Base >

[Rails] Traversing nested ActiveRecord associations

2009-09-08 Thread steven_noble
Let's say... class Town < ActiveRecord::Base has_many :streets has_many :houses, :through => :streets end class Street < ActiveRecord::Base has_many :houses end Then we can find individual streets and houses like this... @first_town = Town.find(:first) @first_towns_first_street = @first_

[Rails] Re: acts_as_tree -- how to pass value of parent via link_to when creating new child

2009-08-07 Thread steven_noble
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 wrote: > Sorry: >

[Rails] Re: acts_as_tree -- how to pass value of parent via link_to when creating new child

2009-08-06 Thread steven_noble
Sorry: <%= link_to("Split Project Into Parts", {:controller=>"projects", :action=>"new", :parent => @project.id}) %> On Aug 7, 8:58 am, steven_noble wrote: > I understand that's how you retrieve the value from the URL. My > question rela

[Rails] Re: acts_as_tree -- how to pass value of parent via link_to when creating new child

2009-08-06 Thread steven_noble
lt;%= link_to("Split Project Into Parts", {:action=>"new_project_path", :parent => @project.id}) %> On Aug 7, 7:21 am, Marnen Laibow-Koser wrote: > steven_noble wrote: > > Hi Marnen, > > > Thanks for sticking with me and sorry for not yet getting it. >

[Rails] Re: acts_as_tree -- how to pass value of parent via link_to when creating new child

2009-08-06 Thread steven_noble
ojects/new with the following? <%= debug :parent %> s. On Aug 7, 7:03 am, Marnen Laibow-Koser wrote: > steven_noble wrote: > > Thanks. I'll try awesome_nested_set. > > > Iian seemed to be suggesting params[:parent] went into projects/new, > > but I'm struggli

[Rails] Re: acts_as_tree -- how to pass value of parent via link_to when creating new child

2009-08-06 Thread steven_noble
Thanks. I'll try awesome_nested_set. Iian seemed to be suggesting params[:parent] went into projects/new, but I'm struggling to get a value to projects/new (via :parents) in the first place, I assume for the reasons you've given. Are you saying that params[:parent] goes into link_to to help me

[Rails] Re: acts_as_tree -- how to pass value of parent via link_to when creating new child

2009-08-06 Thread steven_noble
Thanks Iian. I think the problem might be in my use of the following in the projects/show view: <%= link_to 'Create Subproject', new_project_path, :parent => @project.id %> I have <%= debug @project.id %> in that projects/show view, which gives me: --- 21 However, in the subsequent pro

[Rails] Re: acts_as_tree -- how to pass value of parent via link_to when creating new child

2009-08-06 Thread steven_noble
Thanks Iian. I think the problem might be in my use of the following in the projects/show view: <%= link_to 'Create Subproject', new_project_path, :parent => @project.id %> I have <%= debug @project.id %> in that projects/show view, which gives me: --- 21 However, in the subsequent pro

[Rails] acts_as_tree -- how to create new child

2009-08-05 Thread steven_noble
I have: # In the Projects model... acts_as_tree :order => "name" ### In the Projects/show view... <%= link_to 'Create Subproject', new_project_path, { :parent => @project.id } %> ### In the Projects controller... def new @project = Project.new @project.parent_id = :parent

[Rails] Re: Data-only migrations when User model does not store plain text passwords

2009-07-13 Thread steven_noble
In case anyone else has this a problem, a work-around is to popular the Users table using seed_fu. Then you can just pass it the :password and :password_confirmation, and your app takes care of generating the salted versions etc. s. On Jul 13, 6:19 pm, steven_noble wrote: > Hi all, > &g

[Rails] Re: Data-only migrations when User model does not store plain text passwords

2009-07-13 Thread steven_noble
In case anyone has a similar problem, a workaround is to populate your Users table using seed_fu: http://github.com/mbleigh/seed-fu/tree/master s. On Jul 13, 6:19 pm, steven_noble wrote: > Hi all, > > How do you create a data-only migration for my User model that adds a > passw

[Rails] Data-only migrations when User model does not store plain text passwords

2009-07-13 Thread steven_noble
Hi all, How do you create a data-only migration for my User model that adds a password salt and encrypted password to the Users table? Also, my model validates the equivalence of :password and :password_confirmation, neither of which are columns in the Users table. I need my data-only migration