Ruby on Rails Sunday, October 30, 2011

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@googlegroups.com.
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.

No comments:

Post a Comment