Can someone please tell me what I’m doing wrong here? I get the following error when I try to load my form (/posts/show):
SyntaxError in Posts#show
Showing /Users/fkhalid2008/loand/app/views/posts/show.html.erb where line #10 raised:
compile error
/Users/fkhalid2008/loand/app/views/posts/show.html.erb:10: syntax error, unexpected kENSURE, expecting $end
Extracted source (around line #10):
7: </div>
8: <button type="submit" class="btn span6 large">Submit</button>
9: <% end %>
Here is the relevant code:
POSTS/SHOW
<%= form_remote_tag( :update => 'message', :url => {:controller => 'main', :action => 'send_message', :user_id => @post.user.id }) %>
<br>
<br />
<br />
<div class="field">
Hello! My name is <%= f.text_field :subject %> and I'm contacting you in response to your ad. I'm interested in learning more so get in touch! Here's my contact details: <%= f.text_field :body %>.
</div>
<button type="submit" class="btn span6 large">Submit</button>
<% end %>
You’re trying to use
form_tag_remotewith a block:but you left out the
doto start the block. Your ERB should look more like this:The ERB processor essentially turns the ERB source inside out to produce a blob of Ruby code to execute; that extra step can lead to some very strange looking errors that are difficult to track down. Part of the conversion from ERB to Ruby involves some exception handling, hence the confusing and odd looking
in the error message.