Fetch in applcation

Can someone have a quick gander at this application.rb file

http://pastie.textmate.org/130228

What Im trying to do is make available to controllers lower down a
@recipe so I don’t have to do this in every controller that needs it

recipe = User.find(session[:user_id]).recipe.find(param[:id])

At the top of the controllers that use this I use…

before_filter :authorize
before_filter :fetch_recipe

Say the controller being used for this is an Ingredients controller
(Recipe has many ingredients). What happens is that although I can add
Ingredients it seaams that the flash[:notice] always seams to get set in
the application.rb

Any ideas?

Hi Chris,

I think you can just reset the flash[:notice] to null value in the
beginning of the action.so that it will show the null value or just
check for small condition.

if flash[:notice]

display the message.

end

Chris L. wrote:

Can someone have a quick gander at this application.rb file

http://pastie.textmate.org/130228

What Im trying to do is make available to controllers lower down a
@recipe so I don’t have to do this in every controller that needs it

recipe = User.find(session[:user_id]).recipe.find(param[:id])

At the top of the controllers that use this I use…

before_filter :authorize
before_filter :fetch_recipe

Say the controller being used for this is an Ingredients controller
(Recipe has many ingredients). What happens is that although I can add
Ingredients it seaams that the flash[:notice] always seams to get set in
the application.rb

Any ideas?

Mohan K. wrote:

Cheers for the reply Mohan

I think you can just reset the flash[:notice] to null value in the
beginning of the action.so that it will show the null value or just
check for small condition.

Yeah thats one way around it, the thing is that the flash should not be
being set at all, Ive traced this through and the code seams to happyily
find the recipe so why on earth does it still perform the rescue action

if flash[:notice]

display the message.

end

I’ll check this is set in my view

Thanks for chipping in :slight_smile:

  • Chris

if flash[:notice]

display the message.

end

Hi we do use flash[:notice] in our application but how we use is

Example:

format.js {
render :update do |page|
if @record.save
flash[:success] = ‘Record created successfully!’
@records = Record.find(:all)
page.replace_html ‘admin_table_rows’, :partial=>‘rows’
else
page.replace_html ‘new_record’, :partial => ‘new’
end

    end

    flash[:success] = nil
  }

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs