ruby on rails - form input not saving after submit -
so, let friend work on app today , :url, 'website url' portion of form isn't saving rest is. not sure why happening. went in console , had .save manually show in browser.
<div class="row"> <div class="large-6 columns"> <div class="field"> <%= f.label :title %> <%= f.text_field :title %> </div> <div class="field"> <%= f.label 'website url' %> <%= f.text_area :url %> <----------- field isn't saving anymore. </div> <div class="field"> <%= f.label :tag_list, "genres (separated commas)" %><br /> <%= f.text_field :tag_list %> </div> <p> <%= f.file_field :track%> </p> <div class="actions"> <%= f.submit value: "upload" %> </div> schema snippit
create_table "songs", force: true |t| t.string "title" t.string "artist" t.text "url" t.string "track_file_name" t.string "track_content_type" t.integer "track_file_size" t.datetime "track_updated_at" t.integer "user_id" t.datetime "created_at" t.datetime "updated_at" t.integer "plusminus" end song_controller.rb
class songscontroller < applicationcontroller before_filter :authenticate_user!, only: [:create ,:edit, :update, :destroy, :vote_for_song] before_action :set_song, only: [:show, :edit, :update, :destroy, :vote_for_song] def vote_for @song = song.find(params[:id]) current_user.vote_for(@song) @song.plusminus = @song.votes_for @song.save respond_to |format| format.js { render 'update_votes' } end end def vote_against @song = song.find(params[:id]) current_user.vote_against(@song) respond_to |format| format.js { render 'update_votes' } end end def new_songs @songs = song.order "id desc" end # /songs # /songs.json def index if params[:genre] @songs = song.tagged_with(params[:genre]).paginate(:page => params[:page], :per_page => 15) else @songs = song.order('plusminus').paginate(:page => params[:page], :per_page => 15) end end # /songs/1 # /songs/1.json def show @comment = comment.new(song: @song) end # /songs/new def new @song = song.new end # /songs/1/edit def edit end # post /songs # post /songs.json def create @song = song.new(song_params) respond_to |format| if @song.save format.html { redirect_to @song, notice: 'song created.' } 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 # patch/put /songs/1 # patch/put /songs/1.json 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: :unprocessable_entity } end end end # song /songs/1 # song /songs/1.json 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, :user_id, :tag_list) end end
does adding :url params.require(:song).permit list trick?
Comments
Post a Comment