Suraj
Suraj

Reputation: 2563

exception caught syntax error rails button

I am getting syntaxt error in the below code.

Can someone help me out here.

  <%= button_tag :class => 'pull-right margin-clear btn btn-sm btn-default-transparent btn-animated notify-class', :type => :submit,
      :id =>"notify-class<%=product.master.id%>" :style=>'display:none'    
      :data-toggle => "modal" , :data-target => "#myModal" >         
        Notify me!<i class="fa fa-bell" style ="margin-left: 10px;"></i>
  <% end %>

Upvotes: 0

Views: 38

Answers (2)

Anand
Anand

Reputation: 3770

You are missing commas before :style and before :data-toggle - here is the corrected code:

<%= button_tag :class => 'pull-right margin-clear btn btn-sm btn-default-transparent btn-animated notify-class', :type => :submit,
      :id =>"notify-class<%=product.master.id%>", :style=>'display:none',    
      :data-toggle => "modal" , :data-target => "#myModal" >         
        Notify me!<i class="fa fa-bell" style ="margin-left: 10px;"></i>
  <% end %>

Upvotes: 1

Anthony E
Anthony E

Reputation: 11235

First off, you need a do at the end of your button_tag:

<%= button_tag :class => 'pull-right margin-clear btn btn-sm btn-default-transparent btn-animated notify-class', :type => :submit,
  :id =>"notify-class<%=product.master.id%>" :style=>'display:none'    
  :data-toggle => "modal", :data-target => "#myModal" do %>         
    Notify me! <i class="fa fa-bell" style ="margin-left: 10px;"></i>

Second, you'll need to fix "notify-class<%=product.master.id%>". I'm not exactly sure what you're trying to do here, but you're injecting a <%= %> ERB tag within an existing <%= %> for your button_tag. If you're trying to interpolate a string, use: "notify-class#{product.master.id}", which will work as long as product is defined.

Upvotes: 0

Related Questions