ruby on rails - SyntaxError in SongsController#index -


not sure why seem getting error have appropriate amount of ends. app working - , installed devise , went hell. un-installed devise go working version seem getting error shown below.

error msg

syntaxerror in songscontroller#index /users/user/sites/leap2/leap2/app/controllers/songs_controller.rb:13: syntax error, unexpected end-of-input, expecting keyword_end 

songs_controller.rb

  class songscontroller < applicationcontroller   before_action :set_song, only: [:show, :edit, :update, :destroy]    def index     @songs = song.all   end    def new     @song = song.new   end    def show   end    def edit   end    def create     @song = song.new(song_params)      respond_to |format|       if @song.save         format.html { redirect_to @song, notice: 'song added successully'}         format.json {render action: 'show', status: :created, location: @song}        else         format.html { render action: 'new' }         format.json { render json: @song.errors, status: :unprocessable_entity }        end     end   end    def update    respond_to |format|      if @song.update(song_params)        format.html {redirect_to @song, notice: 'song updated.' }        format.json {head :no_content }      else        format.html {render action: 'edit' }        format.json {render json: @song.errors, status: :unprocessible_entity }      end    end  end     def destroy      @song.destroy      respond_to |format|        format.html { redirect_to songs_url }        format.json { head :no_content }      end    end        private       def set_song        @song = song.find(params[:id])      end       def song_params        params.require(:song).permit(:title, :artist, :bio, :track)      end   end 

show.html.erb

<p id="notice"><%= notice %>       <p>     <strong>title:</strong>     <%= @song.title %>     </p>      <p>     <strong>bio:</strong>     <%= @song.bio %>     </p>      <p>     <strong>audio:</strong>     <%= audio_tag (@song.track.url), controls: "controls" %>     </p>       <br /><br />       <%= link_to 'edit', edit_song_path(@song), class: "button small secondary"%>      <%= link_to 'back', songs_path,  class: "button small secondary" %> 

_form.html_erb

<%= form_for @song, :html => { :multipart => true } |f| %> <% if @song.errors.any? %> <div id="error_explanation">     <h2><%= pluralize(@song.errors.count, "error") %> prohibited song being saved:</h2>       <ul>       <% @song.errors.full_messages.each |msg| %>         <li><%= msg %></li>       <% end %>       </ul>     </div>   <% end %>      <div class="row">         <div class="large-6 columns">     <div class="field">     <%= f.label :title %>     <%= f.text_field :title %>     </div>      <div class="field">     <%= f.label :bio %>     <%= f.text_area :bio %>     </div>      <p>     <%= f.file_field :track%>     </p>      <div class="actions">         <%= f.submit value: "upload" %>     </div>      <% end %>         </div>          <div class="large-6 columns"><h3>submit own song or personal favourite , watch climb charts! </h3>         </div>     </div> 

in application_controller.rb had 1 end.

class applicationcontroller < actioncontroller::base   # prevent csrf attacks raising exception.   # apis, may want use :null_session instead.   protect_from_forgery with: :exception    def authorize     redirect_to new_user_session_path, notice: "you have logged in submit."       if current_user.nil?   end end end 

Comments

  1. Your blog is in a convincing manner, thanks for sharing such an information with lots of your effort and time
    ruby on rails training
    ruby on rails training India
    ruby on rails training Hyderabad

    ReplyDelete

Post a Comment