last day (15 days later) » 

8:34 PM
0
A: How to show error message on rails views?

BurakChange your controller like below def new @simulation = Simulation.new end def create @simulation = Simulation.new(simulation_params) if @simulation.save redirect_to action: 'index' else render 'new' end end Then within your new view, if there exists an error, you can print ...

 
I have added my controller class to question After adding above code in html file I am getting undefined method errors' for nil:NilClass` at <% if @simulation.errors.any? %> because it's not able to find the @simulation parameters
 
edited my answer, redirect_to @simulation what are you trying to do with that line?
 
Still getting the same error
 
yes forgot to reference it. see the edit.
 
Here is my screenshot after editing the views and controller dl.dropboxusercontent.com/u/20476478/… on localhost:3000/simulations/new
 
8:34 PM
sorry my bad, thought i've put the code within the form, instead i misplaced it after form tags.
 
have you edited the controller's new method too?
 
Der?
 
yes I'm here
 
thanks for coming here is my controller
 
8:36 PM
change your controller's new method
 
Sorry I pasted the wrong one
 
as
def new
@simulation = Simulation.new
end
 
oh! :(
thanks :)
it's my mistake
 
its not a problem, did it work?
 
yes. thank you so much :)
 
8:39 PM
welcome :)
 

last day (15 days later) »