Nothing is being inserted into the database...help!

Hello all,

for some reason nothing is being inserted into the database. I have no
idea why not! Here is my action:

  def create
    @information = CalorieKing.new
    @information = CalorieKing.get_information(params[:id])
    @information = @information['food']['servings']
    @information['serving'].each do |s|
      if s['name'] == params[:portion_type]
        s['nutrients'].each do |value|
          value *= params[:size]
        end
        puts 'hello'
        @foodentry = FoodEntry.new(:user_id => current_user.id,
        :name => s['name'], :serving_size => params[:size],
        :serving_name => params[:portion_type], :calories =>
s['nutrients']['caloires'],
        :fat => s['nutrients']['fat'], :carbs => s['nutrients']['carb'],
        :protein => s['nutrients']['protein'], :fiber =>
s['nutrients']['fiber'],
        :sugar => s['nutrients']['sugar'], :sodium =>
s['nutrients']['sodium'],
        :calcium => s['nutrients']['calcium'], :satfat =>
s['nutrients']['satfat'],
        :cholesterol => s['nutrients']['cholesterol'])
        @foodentry.save
        puts 'hello'
      end
    end
    respond_to do |format|
      format.html { redirect_to(food_diary_path) }
      format.xml { head :ok }
    end
  end

Thanks!

Hello all,

for some reason nothing is being inserted into the database. I have no
idea why not! Here is my action:

Did you check for any validations failing

Fred

for some reason nothing is being inserted into the database. I have no
idea why not! Here is my action:

The most common cause is that validations are failing, and you're just
not seeing that.

-- gw

And your controller should be put on a diet...

Frederick Cheung wrote: