目前,我正在将我的应用程序从rails 3.2升级到rails 4.当我导航到特定选项卡时,出现以下错误:
undefined method `raw' for #<LeaseController:0x00000006935e30>
Run Code Online (Sandbox Code Playgroud)
我的代码:
vacant.tenant = raw("Vacant")
vacant.lease_start_date = raw(" ")
vacant.rent_end = raw(" ")
vacant.base_rent_monthly_amount = raw("")
vacant.base_rent_annual_psf = raw("")
vacant.options = raw("")
vacant.security_deposit_amount = raw("")
vacant.tis_amount = raw("")
vacant.lcs_amount =raw("")
Run Code Online (Sandbox Code Playgroud)
为什么这个方法现在未定义?
目前我正在将我的应用程序从rails 3.2升级到rails 4.出现以下错误.
ArgumentError (argument out of range):
Run Code Online (Sandbox Code Playgroud)
由于以下代码行而发生此错误
@lease.update_attributes(params[:lease])
Run Code Online (Sandbox Code Playgroud)
我试过更新,也抛出相同的错误.是否从rails 4中删除了update_attributes.如何使用它?
码:
def terms_build_methods
if @lease.blank?
@lease = params[:current_lease_id].present? ? Lease.find_by_id(params[:current_lease_id].to_i) : Lease.create(params[:lease])
else
@lease.update(lease_params)
end
Lease.update_lease_occupancy_type(@lease)
Lease.update_lease_status(@lease)
end
private
def lease_params
params.require(:lease).permit!
end
Run Code Online (Sandbox Code Playgroud) 我有一个数组,其中包含这样的项目列表
arr = [
{:id=>1, :title=>"A", :parent_id=>nil},
{:id=>2, :title=>"B", :parent_id=>nil},
{:id=>3, :title=>"A1", :parent_id=>1},
{:id=>4, :title=>"A2", :parent_id=>1},
{:id=>5, :title=>"A11", :parent_id=>3},
{:id=>6, :title=>"12", :parent_id=>3},
{:id=>7, :title=>"A2=121", :parent_id=>6},
{:id=>8, :title=>"A21", :parent_id=>4},
{:id=>9, :title=>"B11", :parent_id=>2},
{:id=>10, :title=>"B12", :parent_id=>2},
Run Code Online (Sandbox Code Playgroud)
...]
如果parent_id为nil,那么它应该是父节点,如果parent_id不是nil,则它应该在特定父节点下.
基于id和parent_id,我想提供这样的响应:
-A
-A1
-A11
-A12
-A123
-A2
-A21
-B
-B1
-B11
-B12
Run Code Online (Sandbox Code Playgroud)
我怎么能产生上面提到的回应?
嗨,目前我正在将我的项目从rails 3.2升级到rails 4.升级到rails 4. page.replace_html方法不起作用属性.
例如:
在控制器中如果遇到这样的代码,
渲染:更新do | page |
page.replace_html"lease_container",:partial =>"/ lease/property_pipeline",:locals => {:note_collection => @note}
结束
它抛出这样的错误,
ActionView :: MissingTemplate(缺少模板租约/更新,应用/更新{:locale => [:en],:formats => [:js,:html,:xml,:html,:text,:js,:css ,:ics,:csv,:png,:jpeg,:gif,:bmp,:tiff,:mpeg,:xml,:rss,:atom,:yaml,:multipart_form,:url_encoded_form,:json,:pdf,: zip] ,: handlers => [:erb,:builder,:raw,:ruby,:rjs]}
我怎么能解决这个问题?有什么替代方法可以用jquery做到这一点吗?
将rails应用程序从rails3.2升级到rails 4.我遇到了问题
SessionsController #new中的ActiveRecord :: StatementInvalid
Mysql的::错误:字段'的session_id'没有默认值:INSERT INTO
sessions(created_at,data,updated_at(?,?,?))VALUES
在我的会话表中,我有session_id字段,但我不知道如何设置默认值.
你可以帮我解决这个问题吗?
我的add_sessions_table.rb迁移文件:
class AddSessionsTable <ActiveRecord :: Migration
改变
Run Code Online (Sandbox Code Playgroud)create_table :sessions do |t| t.string :session_id, :null => false t.text :data t.timestamps end add_index :sessions, :session_id add_index :sessions, :updated_at end结束
我的sessions_store.rb文件
MyApp :: Application.config.session_store:active_record_store
谢谢
在一种情况下,我需要加入4个范围中的4个范围,3个是用模型(A)编写的,另一个是模型(B),如何加入这些范围?
这两个模型有HABTM关系
Model A
scope 1
scope 2
scope 3
total_scope= scope1.scope2.scope3.scope4
end
Model B
scope 4
end
Run Code Online (Sandbox Code Playgroud) 我的记录很少,需要检查是否全部blank?:
<% if new_sqft.blank? && executed_sqft.blank? && occupied_sqft.blank? && occ1_res.blank? && expire_res.blank? && termin_res.blank? && vacant_res.blank? && vacant1_res.blank? %>
Run Code Online (Sandbox Code Playgroud)
如何在单行检查?