Upgrade Ruby 1.8 to 2.1 with ActiveRecord 4
Old
Forms were like this, but now they don't render!
<% form_for @seller, :url => "/seller/create" do |f| %>
New
<%= form_for @seller, :url => "/seller/create" do |f| %>
Old
Partial render are also not rendering!
<% seller.fields_for :address do |address_fields| %>
New
<%= seller.fields_for :address do |address_fields| %>
Thanks to jamesw on stackoverflow for this one !
Old
@friendRequests = Friendrequest.all(:conditions => { :friend_id => @user.id, :status => 0 }, :include => :requester )
or
@itemsInCart = Request.all(:conditions => ["offers.active = 1 AND requests.status = 1 AND requests.user_id = ?", @user.id], :joins => "LEFT JOIN offers on offers.id = requests.offer_id")
activerecord (4.2.3) lib/active_record/scoping/named.rb:24:in `all'
app/controllers/products_controller.rb:40:in `index'
New
@friendRequests = Friendrequest.includes(:requester).where(["friend_id = :userid and status = :status", { userid: @user.id, status: 0}]) and @itemsInCart = Request.where(["offers.active = 1 AND requests.status = 1 AND requests.user_id = :user_id", {user_id:@user.id}]).joins("LEFT JOIN offers on offers.id = requests.offer_id")
Old
def store_location session[:return_to] = request.request_uri end
New
def store_location session[:return_to] = request.url end
Old
ActiveSupport::SecureRandom.hex(24)
New
SecureRandom.hex(24)
Old
existingRequest = Signuprequest.first(:conditions => { :unique_id => srequest.unique_id });
This might error with
TypeError (can't convert Hash into Integer)
New
intHex = Integer(srequest.unique_id, 16) existingRequest = Signuprequest.where(:unique_id => intHex.to_s).first;
Old
@purchase = Purchase.first(:conditions => { :user_id => @user.id }, :order => "created_at DESC");
New
@purchase = Purchase.where(:user_id => @user.id).order("created_at DESC");
Old
UserMailer.deliver_welcome_email(@user, srequest.unique_id, websitename, request.host)
New
UserMailer.welcome_email(@user, srequest.unique_id, websitename, request.host).deliver
See more at UserMailer:Class undefined method error post
Old
undefined method `error_messages' for #<ActionView::Helpers::FormBuilder:0x0000000dccb098>
<% form_for @seller, :url => "/seller/create" do |f| %>
<%= f.error_messages %>
New
<% form_for @seller, :url => "/seller/create" do |f| %>
<% @seller.errors.full_messages.each do |msg| %>
<p><%= msg %></p>
<% end %>
Old
undefined method `url_for_file_column' for #<#<Class:0x00000012c13fb0>:0x00000012c12700>
Solution is found in how to migrate from FileColumn to CarrierWave
Troubleshooting
ActiveModel::ForbiddenAttributesError
@seller = Seller.new(params[:seller])
Recent Comments