Tag: 的Ruby on 轨道

未找到参数:发电机

即时尝试与第二个模型(生成器)一起构建我的第三个模型(结果)。 我从我的Generator show.html.erb调用结果表单,当我单击表单中的提交按钮时,我得到此错误param not found: generator 的routes.rb resources :users do resources :generators resources :results end 生成器show.html.erb … Binding Time Analysis Result.controller def new @result=Result.new end # GET /results/1/edit # POST /results # POST /results.json TGATGAACATCATGATGAGGTGATGACATCACATCATTGACTGATGCATCATGATG def create @result = @generator.build_result(result_params) @result=@result.generate_result(result_params) @generator.result.save redirect_to user_generators_path end def result_params params.require(:result).permit(:ncbi_ref_seq,:genome_seq,:genome_sample,:binding_times,:amp_frags,:seqpos1,:seqpos2) end User.rb class User :generators Generator.rb class […]

节点预期,得到String

我正在尝试构建一个树结构,所以我创建了一个带有自连接关联的Node模型: class Node “Node”, :foreign_key => “parent_id” belongs_to :parent, :class_name => “Node” 这是架构: create_table “nodes”, :force => true do |t| t.integer “key” t.decimal “value”, :precision => 8, :scale => 2 t.decimal “prob”, :precision => 8, :scale => 2 t.integer “parent_id” t.datetime “created_at” t.datetime “updated_at” end 当我运行测试或通过控制台创建节点时,一切似乎都运行正常。 但是,当我运行应用程序并通过/ nodes / new上的表单创建一个新节点时,我收到以下错误: ActiveRecord::AssociationTypeMismatch in NodesController#create Node(#2162787060) expected, […]

通过facebook,gmail,twitter等在rails应用中找到朋友

我已经在rails中构建了一个社交网络应用程序,我正在寻找一种简单的方法来允许用户登录其他各种帐户(OAuth?),如facebook,twitter,gmail,其他邮件客户端等,看看他们的朋友/是否这些网站上的联系人已注册我的网站。 此外,我将添加function,允许用户通过这些相同的网站邀请他们的非注册好友访问我的网站。 在将来,我还希望这样做,以便用户可以在我的网站上将这些提交内容发布到这些不同的其他网站。 但此时,最重要的function是让用户能够看到这些其他网站上的哪些联系人已注册我的网站。 最好的方法是什么? 我应该寻找什么gem(OAuth,RFacebook,Facebooker等)。 我目前正在使用restful身份validation(此外,有人可以指向我的方向,回答如何允许用户登录,使用其他身份validation,使用他们的用户名或他们的电子邮件吗?) 谢谢!

使用考拉在Facebook上发布带有标签的照片

我正在尝试使用以下代码使用Koela发布照片,但它没有对用户进行分类 @graph.put_picture(pic_url,{:message => msg,:tags => [{:id => “xxxxxxx”} ,{:id=>”xxxxxxx”}]}) 这是facebook链接,但它是用PHP http://developers.facebook.com/docs/reference/api/photo/

Ruby on Rails过滤返回模型对象的属性

我正在为Rails应用程序创建一个API,我想为API调用返回User对象,但没有crypted_password , salt或login_token属性。 有没有办法做这样的事情: do api_fetch_user(u) user=User.find(u) return user(:filter=>”crypted_password”, “salt”, “login_token”) end

如何使用restforce gem在rails上的ruby中使用salesforce帐户对象获取所有关联数据

我正在尝试使用restforce REST Api从salesforce获取所有用户数据。我有salesforce帐户对象。 现在我想用这个帐户对象获取所有相关数据。

现有工作应用程序上的“rails server”无法启动

我很高兴配置我的新笔记本电脑来处理我现有的项目。 我复制了一个应用程序及其所有子文件夹的文件夹,现在将它放在新笔记本电脑中。 看来我无法通过在项目的根目录键入rails server命令来启动服务器。 我试图创建一个新项目并启动它并且它工作正常,所以我真的不知道该怎么做。 Rails版本是相同且相同的Gemfile 。 这是rails server命令的结果: Usage: rails new APP_PATH [options] Options: -r, [–ruby=PATH] # Path to the Ruby binary of your choice # Default: /home/toni/.rvm/rubies/ruby-1.9.3-p374/bin/ruby -b, [–builder=BUILDER] # Path to a application builder (can be a filesystem path or URL) -m, [–template=TEMPLATE] # Path to an application template (can be a […]

显示在postacts_as_votable上投票的用户

我正在使用acts_as_votable gem并已实现它,以便用户可以对post模型进行投票。 我想要做的是当我显示我想列出用户投票的post时。 我目前显示的分数是: 在post/ index.html.erb这很好用。 我无法理解如何显示投票的用户。 理想情况下,我想显示user.image。 这是到目前为止的代码: 模型/关注/ votes.rb def up_vote @post = find_post @post.liked_by current_user flash[:notice] = “Thanks for voting #{current_user.name}” redirect_to @post end Iv添加它,以便用户是选民,post是可投票的。 我还添加了缓存迁移: class AddCachedVotesToPosts 0 add_column :posts, :cached_votes_score, :integer, :default => 0 add_column :posts, :cached_votes_up, :integer, :default => 0 add_column :posts, :cached_votes_down, :integer, :default => 0 add_column :posts, […]

索引名称太长,无法回滚迁移

我在git分支上并试图在销毁分支之前回滚两次迁移。 最近的迁移会向我要保留的表添加一列(并且它是master的一部分,而不是要删除的分支),因此删除整个表不是解决方案(除非我必须再次重新创建它)。 无论如何,我一定做错了,因为当我试图从得分表中删除apple_id列时,我得到了这个中止错误。 这是我正在尝试回滚的迁移 add_column :scores, :apple_id, :integer 但是,错误消息(参见下文)是指我使用创建表的原始迁移(master分支的一部分)创建的索引 add_index :scores, [:user_id, :created_at, :funded, :started] 你能建议我做什么吗? == AddAppleidColumnToScores: reverting ======================================= — remove_column(“scores”, :apple_id) rake aborted! An error has occurred, this and all later migrations canceled: Index name ‘temp_index_altered_scores_on_user_id_and_created_at_and_funded_and_started’ on table ‘altered_scores’ is too long; the limit is 64 characters 更新:阅读此SO问题如何在使用MySQL的Ruby on Rails迁移中处理太长的索引名称? ,我得到了一些关于问题根源的更多信息,但不知道如何解决它。 sql和postgres都有64个字符限制 Index […]

在Rails 2.3中对嵌套对象进行排序

我有一个带有嵌套对象的表单,如下所述: http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes 它工作正常,但我需要通过“name”属性对表单中的嵌套对象进行排序,以便按字母顺序列出。 有任何想法吗?