Search Results

Search found 2 results on 1 pages for 'gigg'.

Page 1/1 | 1 

  • PRoblem with converting form_tag in rails

    - by Gigg
    I am new to ruby and rails and I am having a problem from Beggining Ruby on Rails Ecommerce. (Yes, its an old book). I have these 2 code sets for a view: new.html.erb: <%= form_tag :action= 'create' do -% <%= render :partial = 'form' % <%= submit_tag 'Create' % <%= end -% <% link_to 'Back', :action = 'index' % _form.html.erb: <% error_messages_for 'supplier' % First Name Last Name But It wont show although I added the do option. It keeps giving me this error: C:/rails/emporium/app/views/admin/supplier/new.html.erb:1: syntax error, unexpected ')' ...orm_tag :action= 'create' do ).to_s) ... ^ C:/rails/emporium/app/views/admin/supplier/new.html.erb:4: syntax error, unexpected keyword_end ; @output_buffer.concat(( end ).to_s) ^ C:/rails/emporium/app/views/admin/supplier/new.html.erb:5: syntax error, unexpected tIVAR, expecting ')' @output_buffer.concat "\n" ^ C:/rails/emporium/app/views/admin/supplier/new.html.erb:7: syntax error, unexpected keyword_ensure, expecting keyword_end C:/rails/emporium/app/views/admin/supplier/new.html.erb:9: syntax error, unexpected $end, expecting ')' Can anyone suggest how I fix this since I have not fould a google answer yet. Thanks Gigg

    Read the article

  • Adding Mysql Columns in Rails Rake

    - by Gigg
    I have a rake file that does a series of calculations on a database. Basically it adds usage on equipment regularly. At the end of the day it needs to add that days total to a monthly total table and update that same table. i use the following simple concepts: To get data from the database is pretty simple: @usages = Usage.find(:all) time = Time.new for usage in @usages sql = ActiveRecord::Base.connection To insert it into the database: sql.execute "INSERT (or UPDATE) into usages ## add values and options as per MySQL But how do I: take a column from a database, add all of its values together that have a common value in another column, (i.e. if column x == value y) and then insert it into another column in another table, say dailyusages? I have tried these options: task (:monthly => :environment) do @dailyusages = Dailyusage.find(:all) for dailyusage in @dailyusages sql = ActiveRecord::Base.connection time = Time.new device = monthlyusages.device month = time.month if device == dailyusages.device ##&& month == dailyusages.month total = (dailyusage.total.sum.to_i) @monthlyusages = Monthlyusage.find(:all) for monthlyusage in @monthlyusages sql = ActiveRecord::Base.connection old_total = monthlyusage.total.to_i new_total = (old_total + total) sql.execute "UPDATE monthlyusages ( year, month, total, device ) values('#{time.year}', '#{time.month}', '#{total}', '#{dailyusage.device}' )" end I obviously have uncommented options and tried all sorts of things. Any help would really save me a load of trouble. Thanks in advance. (** BTW - I am new to rails, so go easy on me **)

    Read the article

1