Hello,

render :action => :create only renders the template for the create
> action, it doesnt run the actual action, thats why the before filter
> doesnt get called.
>

But if you look at the sample code, I did try to call the "Create" method as
well as rendering its template:

     elsif params["create"]
         # Called from the confirmation page where there will
         # be a button with name "create"
         create
         render :action => :create
         return



> Why are you going with one controller action and the if/elsif/else
> solution instead of just separating steps into different controller
> actions?
> --
>

The two controller actions are required because of 2 different security
requirements.

The before_filter :require_user only applies to the "Create" controller
action, and shouldn't be a requirement for "Confirm" or for filling out a
"New" entry.

>From the Confirm action there is also a need to allow a "Back" step (via
posting back the params again) and this also shouldn't require a user
constraint.

A poor-man's solution is to manually call the "require_user" method at the
top of the create function - but this doesn't seem elegant and bypasses the
whole point of the before_filter.

What I don't understand is why doesn't the *_filters run on _every_
invocation of all Controller methods (including being called from
within another method) and not just when it is called via the normal means
of handling a routing request?

Another possible solution is of course to place 2 buttons on a page that
would point to 2 different action action handlers - but I don't know how one
would go about doing this without JavaScript and still be DRY.

If you have other suggestions keep it rolling :)

- Chris

-- 
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