What is the correct way to use the form tag, I am getting a compile error when I include the end. When I take it out it works, should I just manually end the form with HTML? Or is there something wrong with my syntax?
<html>
<head>
<title>
Databse connections
</title>
</head>
<body>
<%= form_tag ( :action => 'create' )%>
<%= text_field(:album, :title) %>
<%= text_field(:album, :artist) %>
<%= text_field(:album, :genre) %>
<%= datetime_select(:album, :release_date) %>
<%= submit_tag("Create") %>
<% end %>
</body>
</html>
If you use
form_tagwithout a block, it’ll only create the opening tag. If you want to create both tags, you need to pass it a block, which you appear to be trying to do, but you are missing thedokeyword afterform_tag(...):Without
doto start the block, theendis a syntax error. Without theendin your current syntax, you are not specifying that the fields are to be within the form (but they will end up being part of your form because you aren’t closing your form tag created by the block-lessform_tagbefore specifying them).