On Sep 23, 2010, at 12:04 PM, mactrooper wrote:

> I'm trying to make it easier on the user by pre-filling some form info
> from a has_many through model relationship.  A person has_many
> addresses, we pick one of those Addresses and create and Event that is
> under a Project.  The link on the Address card looks like:
> 
> /projects/1/events/new?street=1234 Test Street&city=myCity
> 
> Then a little param help in the Events Controller helped pre-fill the
> form
> 
>  def new
>       hobo_create Event.new(
>        :street => params[:street],
>        :city => params[:city],
>  end
> 

I'm assuming you meant hobo_new here, as hobo_create would save to the DB...

> This was working in Hobo 0.7.0, but now it doesn't pre-populate the
> forms in 1.0.  It won't put the values in the form.
> 
> Ideally I'd like to not pass the params via the URL (security), just
> the id of the Address from which we should take the params.  But I
> can't get it to pass the parameters.  In fact, I cant even get the
> DRYML to override for /projects/1/events/new  The file in
> views>events>new.dryml doesn't effect the output at all.  Its coming
> from somewhere else.  I there another location for nested routes?  Is
> there a better way to pass parameters via URL?  Thanks in advance!

I can't remember when it was added, but requests to that format of URL 
(/projects/:project_id/events/new) are now routed to a new_for_project action 
in the controller; that explains why the view file isn't having an effect. This 
should do what you're looking for (in EventsController):

def new_for_project
  hobo_new_for :project, Event.new(...set up whatever here...)
end

--Matt Jones

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" 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/hobousers?hl=en.

Reply via email to