Render alternate view in ruby on rails?

Up vote 1 down vote favorite share g+ share fb share tw.

I have the following code in my controller def create @severity = Severity. New(params:severity) if @severity. Save flash:notice = "Successfully created severity" render 'save' end end I am trying to get the method to render another view file other than create.js.

Erb however the controller always renders the default rather than the save.js.erb. Any ideas on what could be wrong? Ruby-on-rails-3 view render link|improve this question asked Apr 10 '11 at 18:14Binary X642216 83% accept rate.

Def create @severity = Severity. New(params:severity) if @severity. Save flash:notice = "Successfully created severity" respond_to do |format| format.

Js { render :template => "/path/to/save" } end end end or def create @severity = Severity. New(params:severity) if @severity. Save flash:notice = "Successfully created severity" respond_to do |format| format.

Js { render :file => "/path/to/save.js. Erb" } end end end try this def create @severity = Severity. New(params:severity) if @severity.

Save flash:notice = "Successfully created severity" end render :file => "/path/to/save.js. Erb" end.

This did not work, I added the render template version of the code pointing to severities/save and it still rendered the default create.js. Erb file. Do I need to include the full path?

– Binary X Apr 10 '11 at 19:10 how do you cal this action? Through ajax? – fl00r Apr 10 '11 at 19:18 Yes I have a form_for with the :remote => true attribute – Binary X Apr 10 '11 at 19:21 ok, see my update.

– fl00r Apr 10 '11 at 19:24 Still no luck, despite which method I use to try and render another view it always defaults to rendering create.js. Erb – Binary X Apr 10 '11 at 20:25.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions