views:

247

answers:

1

Hi community

In my controller i have

look the commented line, i need dynamic minutes to @presentation.date

def create
    @presentation = Presentation.new(params[:presentation])
    @presentation.user_id = current_user.id
    @category = Category.find_by_id(params[:presentation][:category_id])
    @addtime = params[:presentation][:date]
#####@presentation.date = @category.date + @addtime.minutes ---------------------------- With this line not work 
    @presentation.date = @category.date + 60.minutes
    @presentation.expiration = @category.date + 3.days

    respond_to do |format|
      if @presentation.save
        flash[:notice] = 'Presentation was successfully created.'
        format.html { redirect_to(@presentation) }
        format.xml  { render :xml => @presentation, :status => :created, :location => @presentation }
      else
        @addtime = params[:presentation][:date]
        @category = Category.find_by_id(params[:presentation][:category_id])
        @minutes = Minute.minutes_presentations(params[:presentation][:category_id])
        format.html { render :action => "new" }
        format.xml  { render :xml => @presentation.errors, :status => :unprocessable_entity }
      end
    end
  end
+2  A: 

minutes isn't a method on String. You need to convert your param to a number first.

@presentation.date = @category.date + @addtime.to_f.minutes
jdl