Tag: ruby on rails 4

Rails 4 form_for error:ActionController的未定义方法`model_name’::参数:Class

我正在尝试创建一个用于创建用户记录的基本表单: 在控制器中: def create_user @user = params[:user] @user = User.new if !@user end 这加载正常,没有错误,但是当我提交表单时,我收到以下错误: NoMethodError in Admin#create_user Showing /Applications/MAMP/htdocs/clippo2/app/views/admin/create_user.html.erb where line #6 raised: undefined method `model_name’ for ActionController::Parameters:Class Extracted source (around line #6): 这是我的路线: get “admin”, to: “admin#index” get “admin/edit_user/:id”, to: “admin#edit_user” patch “admin/edit_user/:id”, to: “admin#edit_user” get “admin/create_user” post “admin/create_user” get “admin/delete_user” get “access/login” get […]

Link_to有两个参数不起作用

在组织的页面上,我有一个部分显示具有该组织的主持人角色的用户。 在每个用户/主持人后面都有一个删除该角色的链接。 但是,此链接无效。 单击它时,没有任何反应。 在浏览器的url栏中,它只显示新文本: https://url/organizations/ek99?data[confirm]=Are+you+certain%3F&data[method]=post&data[organization_id]=100&data[stakeholder_id]=113&data[url]=%2Fremovemoderator%2Fek99 。 有没有人可能会看到这段代码有什么问题? 在组织控制器中 : def show @organization = Organization.friendly.find(params[:id]) @moderators = User.with_role(:moderator, @organization) end 视图页面使用调用部分 。 部分包含每个主持人的链接: 路线 : post ‘removemoderator/:id’=> ‘users#remove_moderator’, as: ‘removemoderator’ 用户控制器方法 : def remove_moderator @organization = Organization.friendly.find(params[:id]) remove_modrights(@organization) end 用户模型方法 : def remove_modrights(organization) self.remove_role :moderator, organization end

使用mingw编译mysql2时出现分段错误

当我尝试创建一个Rails服务器时,这就是我得到的。 它立即运行超过500行代码并返回此消息。 这是我的第一个Ruby on Rails项目。 我对编码也很陌生。 如果可能的话,会爱一些帮助。 谢谢! C:/Ruby200-x64/lib/ruby/gems/2.0.0/extensions/x64-mingw32/2.0.0/mysql2-0.3.15/my sql2/mysql2.so: [BUG] Segmentation fault ruby 2.0.0p451 (2014-02-24) [x64-mingw32] 0 enumerator.so 1 C:/Ruby200-x64/lib/ruby/2.0.0/x64-mingw32/enc/encdb.so 2 C:/Ruby200-x64/lib/ruby/2.0.0/x64-mingw32/enc/iso_8859_1.so 3 C:/Ruby200-x64/lib/ruby/2.0.0/x64-mingw32/enc/trans/transdb.so 4 C:/Ruby200-x64/lib/ruby/2.0.0/x64-mingw32/rbconfig.rb 5 C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/compatibility.rb 6 C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/defaults.rb 7 C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/deprecate.rb 8 C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/errors.rb 9 C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/version.rb 10 C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/requirement.rb 11 C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/platform.rb 12 C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/basic_specification.rb 13 C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/stub_specification.rb 14 C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/util/stringio.rb 15 C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/specification.rb 16 C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/exceptions.rb 17 C:/Ruby200-x64/lib/ruby/2.0.0/rubygems/defaults/operating_system.rb 18 C:/Ruby200-x64/lib/ruby/2.0.0/x64-mingw32/enc/utf_16le.so […]

从用户分组显示消息表中的最新消息

我正在尝试为用户之间的消息传递创建一个收件箱。 以下是表格: Messsages Id | Message_from | message_to | message 1 | 2 | 1 | Hi 2 | 2 | 1 | How are you 3 | 1 | 3 | Hola 4 | 4 | 1 | Whats up 5 | 1 | 4 | Just Chilling 6 | 5 | 1 | […]

从gmail中的多个帐户导入联系人

我有一个rails应用程序,我正在使用omnicontacts gem从yahoo,gmail和outlook.Its导入联系人工作正常。但是一旦我从任何帐户导入联系人说gmail,并尝试从另一个帐户导入联系人它不会问我使用其他帐户登录以从中导入联系人。 这是我的omnicontacts initializer 。请帮助,我可以根据需要添加更多信息。 配置/初始化/ omnicontacts.rb Rails.application.middleware.use OmniContacts::Builder do importer :gmail, ENV[‘GMAIL_ID’], ENV[‘GMAIL_SECRET’], redirect_path: ‘/invites/gmail/contact_callback’, max_results: 1000 importer :yahoo, ENV[‘YAHOO_ID’], ENV[‘YAHOO_SECRET’], callback_path: ‘/invites/yahoo/contact_callback’, max_results: 1000 importer :outlook, ENV[‘OUTLOOK_APP_ID’], ENV[‘OUTLOOK_APP_KEY’], redirect_path: ‘/invites/outlook/contact_callback’, max_results: 1000 end

Rails redirect_to页面的一部分

对于正常的重定向,它将类似于redirect_to root_path 。 我将如何重定向到: localhost:3000/#contact 。 我不想直接重定向到root,而是想重定向到root,还要重定向到根页的contact部分。 这可能吗?

rails server(4.0.0)无法启动 – 错误:LoadError:8 lib / mysql2.rb:8:in`require’:libmysqlclient.so.18

我无法启动我的rails服务器。 错误显示: $ rails server /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.13/lib/mysql2a.rb:8:in `require’: libmysqlclient.so.18: cannot open shared object file: No such file or directory – /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.13/lib/mysql2/mysql2.so (LoadError) from /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.13/lib/mysql2.rb:8:in `’ from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require’ from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require’ from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each’ from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require’ from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each’ from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require’ from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler.rb:132:in `require’ from /home/marslo/Study/Codes/Ruby/RailsBegin/config/application.rb:7:in `’ from […]

使用常量在控制器中存储列名称以存储参数?

问题:此实施是否存在安全风险或其他问题? 我这样做的原因是因为我不想为每个表单输入键入f.text_field :field_name 。 这似乎是最干的方法。 主要关注点 :常量是否未得到执行,并且想知道这种实现是否存在安全风险? class UserController < ApplicationController def index end def new @user = User.new @fields = USER_FIELDS end def create render text: params.inspect end private USER_FIELDS = ["first_name", "last_name", "email", "password"] def require_parmas params.require(:user).permit(USER_FIELDS) end end 用户#new view

Ruby on Rails gem’byebug’安装错误

我该如何解决这个错误? 当我使用此命令检查演示创建的网站中的rails版本时,会创建此问题。

需要有关rails 4中动态表格内容计划的帮助

我需要你的帮助来计划我的想法。 首先,我向您展示我想要发布的内容: ![在此处输入图像说明] [1] 有一个html表,应该有一个上面的内容(标题日期,标题,时间,位置)。 如您所见,这是一个时间表。 模型: 有一个用户模型,它包含一个schedule-column作为数组,因为我不想使用关系行为。 所以我只想在这个数组中保存schedule-model-name。 此外,还有一个计划模型,其中包含日期,标题,时间,位置和访问的用户arrays。 对RoR专家的致辞:感谢belongs_to -suggestion,但我不明白,我必须在口语考试中解释我的决定,所以我只想用,我真正理解。 控制器: 处理对计划模型的访问,例如@all 。 我认为这对我没有任何问题。 视图: 这就是我需要你帮助的地方。 我搜索了类似“动态表格内容”的内容,发现了这个: [从Ruby中的哈希数组生成一个HTML表格] [2],但我真的不明白他们的任何答案.. 在输入这个问题时,我意识到我应该在Controller中做更多@all 。 一天进行多次预约也很重要。 如果时间相似或相同,则约会应平行显示。 如果时间不相似,则约会应相互显示。 (图中未显示) 我也希望有人能抽出时间帮忙。