Search code examples
ruby-on-railsmodelcontrollerflash-message

are controllers necessary to send flash messages in rails?


this is kind of a newbie question, sorry but...if a model has no controllers, how could i perform a

flash[:notice]? 

for example in

https://github.com/tute/merit

i noticed that it just has models and no controllers. i know that it would be wise to put the flash message inside a controller as opposed to the methods that get executed in the models, but.... how can i do this if there is no controller?

i could try to create one but then doesn't each action in the controller correspond to a page in the view?

certain methods are being executed in the models and i want to be able to add a flash[:notice] whenever they get executed but...how would i do this?

thank you


Solution

  • You would still set flash messages in a controller (or anywhere else the session can be accessed, technically). Merit is just an add-on for Rails, not a replacement. You would still use controllers in your application to handle requests from the user.