hey all,
I have this:
scope :path => ''/activation'', :controller =>
:activation do
post "create" => :create
get "confirmation" => :confirmation, :as =>
"confirmation"
get "send_activation_notification"
=> :send_activation_notification, :as => "send_activation" do
resources :users do
resources :accounts
end
end
end
After an activation is created:
def create
if acc_a_usr = @activation.perform
extract_contents acc_a_usr
send_activation_notification @user, @account
render :action => "confirmation"
else
render "new"
end
end
confirmation view loads:
= link_to "Resend Email", send_activation_path(@user, @account)
That link gets directed to this method (this method gets called in
multiple places so must account for multiple situations):
def send_activation_notification(user=nil, account=nil)
user = user || params[:user]
account = account || params[:account]
CreateAccount.create_account(user, account).deliver
end
Now I look at the url generated by this helper and it''s not right:
send_activation_notification.33?=59
it should be:
send_activation_notification/user/33/account/59 (so that I can access
these ids in the params hash)
I have rea the book "The Rails 3" way and their example of doing what
I want is somehting like this:
resources :actions do
resources :bids
end
In my code I try to mimic something similar:
get "send_activation_notification"
=> :send_activation_notification, :as => "send_activation" do
resources :users do
resources :accounts
end
end
But it doesn''t work for me. Note that send_activation_notification is
not a restful route, so I couldnt model my code exactly as shown in
the rails book.
thanks for response
--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
John Merlino
2011-Oct-31 15:33 UTC
Re: nested routes not rendering properly in link helper
This was easy resolution: send_activation_notification(:user_id => @user.id, :account_id => @account.id) That will pass the params in query string -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sunday, October 30, 2011 9:31:50 PM UTC-4, John Merlino wrote:> > > get "send_activation_notification" > => :send_activation_notification, :as => "send_activation" do > resources :users do > resources :accounts > end > end > > But it doesn''t work for me. Note that send_activation_notification is > not a restful route, so I couldnt model my code exactly as shown in > the rails book.That''s not a valid route at all. I think you might have it backwards. Check out the results of "rake routes" if you need to see what all your routes look like. Instead of this: get "send_activation_notification" => :send_activation_notification, :as => "send_activation" do resources :users do resources :accounts end end You might want to do something like this: resources :users do get ''send_activation_notification'', :on => :member resources :accounts end Then you will have a send_activation_notification_user route that you can use. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/xspDQecxa7gJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
John Merlino
2011-Nov-01 23:20 UTC
Re: nested routes not rendering properly in link helper
thanks for response, the solution I provided also works if you want to pass params in hash via query string when there isn''t a direct association between multiple models On Oct 31, 3:26 pm, Tim Shaffer <timshaf...-BUHhN+a2lJ4@public.gmane.org> wrote:> On Sunday, October 30, 2011 9:31:50 PM UTC-4, John Merlino wrote: > > > get "send_activation_notification" > > => :send_activation_notification, :as => "send_activation" do > > resources :users do > > resources :accounts > > end > > end > > > But it doesn''t work for me. Note that send_activation_notification is > > not a restful route, so I couldnt model my code exactly as shown in > > the rails book. > > That''s not a valid route at all. I think you might have it backwards. Check > out the results of "rake routes" if you need to see what all your routes > look like. > > Instead of this: > > get "send_activation_notification" => :send_activation_notification, :as => > "send_activation" do > resources :users do > resources :accounts > end > end > > You might want to do something like this: > > resources :users do > get ''send_activation_notification'', :on => :member > resources :accounts > end > > Then you will have a send_activation_notification_user route that you can > use.-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.