Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

form_for not showing up

I have a model called "ExpDemo" and want to use it from "MainController."

I setup the code like this:

main_controller.rb

def pre
  @demo = ExpDemo.new
end

main/pre.html.erb

<% form_for(@demo) do |f| %>
  ...
<% end %>

Until here, I experienced 'path' error.

undefined method `exp_demos_path'

So, I added following to routes.rb and the error message gone.

resources :exp_demos

Now, the form is not showing up in the HTML page. I think the routing setup is the problem, but I'm not sure how to fix it. Please help me to resolve this issue.

like image 847
monodev Avatar asked Feb 23 '13 13:02

monodev


1 Answers

you forgot an = for the form_for

<%= form_for(@demo) do |f| %>
like image 141
jvnill Avatar answered Sep 18 '22 12:09

jvnill