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! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2010-Sep-04 21:11 UTC
Re: Nothing is being inserted into the database...help!
On 4 Sep, 20:23, Zack Nathan <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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> 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! > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Greg Willits
2010-Sep-04 21:58 UTC
Re: Nothing is being inserted into the database...help!
> 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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Fernando Perez
2010-Sep-04 22:14 UTC
Re: Nothing is being inserted into the database...help!
And your controller should be put on a diet... -- http://digiprof.tv -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung wrote:> On 4 Sep, 20:23, Zack Nathan <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> 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 > > FredYep sorry, Iv been busy and hadnt checked my email for replies. You guys were right I had a type in the name of my validation so i fixed it and now it works great! Of course my controller needs to loose some weight, i just need to get the app working and show the client a working copy then im going refractor pretty much all my code! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.