Tag: ruby on rails 3

如何将特定gem冻结到Rails 3应用程序中?

我的问题非常类似于如何将Gems冻结到Rails 3应用程序中? ,但我只想冻结一个修改过的gem。 这个问题的答案似乎导致捆绑所有应用程序的gem。 如果它是相关的,我需要这样做,以便修改后的gem安装在Heroku上。 我检查了bundle-install doc,但它似乎没有解决这种情况。 但我无法想象这种情况并不常见。 任何指导表示赞赏。

Rails SQL插入语句未显示在控制台中

我的终端用于显示SQL表插入语句(默认情况下应该这样),现在它没有。 其他所有内容 – 例如,GET请求,本地服务器启动信息或作业完成通知 – 都显示为正常。 对于我的生活,我无法弄清楚问题是什么。 我一直在寻找很长一段时间,无法弄清楚这会发生什么原因。 你有什么想法指出我正确的方向吗?

Rails:如何将模型的详细信息打印到A4 PDF页面?

在我的工作管理应用程序中,我想为客户准备A4页面收据。 因此,我需要以某种方式将Job模型的详细信息打印到单个A4 PDF页面。 Rails中的任何内置工具都是为此目的吗? 如果不是,最好的方法是什么?

尝试使用Best In Place更新索引中的记录

我试图使用单独的jQuery或就地编辑器“Best In Place”来更新索引中的记录。 没有获得复选框并且在行上丢失格式。 我使用这个rails cast作为指南但是当我使用Ryan使用的复选框上的语法时,我得到一个错误说: 更新:Ruby 1.8.7 语法错误,意外’:’,期待’)’ 码 – application.js中: //= require jquery //= require jquery_ujs //= require_tree . //= require jquery.tablednd_0_5.js //= require jquery.tablesorter.js //= require jquery.purr //= require best_in_place 评论,crb_agenda和pre_release_agenda咖啡脚本: jQuery -> $(‘.best_in_place’).best_in_place() comments_controller.rb#更新 def update @comment = Comment.find(params[:id]) respond_to do |format| if @comment.update_attributes(params[:comment]) Comment.add_comment_to_jira_ticket(“MCTEST-293”,@comment.user_comments) format.html { redirect_to @comment, :notice => […]

Carrierwave无法上传 – 未显示错误

我整晚都在努力,这没有任何意义。 我正在改编一个旧的照片网络应用程序,以便在其中添加相册。 我制作了“失败”(基本上是图片)相册的嵌套资源。 我使用carrierwave将文件上传到S3存储桶。 奇怪的是:上传对于专辑模型(专辑图片)完全正常,但不会为故障模型上传。 我不明白为什么它现在是一个嵌套资源的问题。 显示它并不是一个问题,因为它出于某种原因,它通过forms正常,传递validation正常,没有错误被抛出,它重定向到失败#index成功,但数据库或S3中没有任何内容。 代码如下。 所有代码都在https://github.com/spq24/failboard 失败模型 class Fail 200 } validates :album_id, presence: true validates :image, presence: true validates :fail_title, presence: true, length: { :maximum => 50 } validate :maximum_amount_of_tags def maximum_amount_of_tags number_of_tags = tag_list_cache_on(“tags”).uniq.length errors.add(:base, “Please only add up to 5 tags”) if number_of_tags > 5 end before_save :update_attachment_attributes def […]

运行rails生成scaffold不会生成模型

如果我输入(完全复制/粘贴“rails g scaffold –help”) rails generate scaffold purchase amount:decimal tracking_id:integer:uniq 然后创建控制器,视图,创建模型..但它不包含任何属性。 它实际上包含: class Purchase < ActiveRecord::Base end 我错过了什么吗? 版本 Rails 3.2.0 ruby 1.8.7(2010-01-10 patchlevel 249)[universal-darwin11.0] Mac OSX Lion

如何在Rails中使用API​​返回嵌套注释

has_many :comments都有has_many :comments关联 我有以下方法来归还我的车: class Api::V1::CarsController recent) end end 我最近获得了以下汽车: curl -X GET http://cars.dev/api/v1/cars/recent -d “token=zzxWkB3SzDP3U1wDsJbY” -d “how_recent=20” 我希望得到这样的回应: “recent_with_comments”:{“recent”:[{“type”:”ferrari”,”price”:null,”user_id”:78,”username”:null,”comments”:[{“id”:1, “comment”: “some text”},{“id”:2, “comment”: “some text 2”}]}]

设计用户ID会在自动增量中跳过多个数字

我有一段代码,以编程方式创建一个新的设计用户: user = User.new user.username = params[:username] user.email = params[:email] user.password = params[:password] if user.save render :json => user else render :json => user.errors end 我最近注意到user id在我的记录中跳过了大约30个数字。 看着我的记录,我有: 知道什么可能导致增量的这个巨大差距? 用户无法删除其帐户。

HTML在Rails 3中转义

我在这个视图中有一个方法调用 拆分下面的字符串 “Listings Listing changes Flagged Items Transfers Reviews Log Indexer Compensations Users” 我只是在我的页面中得到这个字符串。 我希望它们是由CSS完美设计的菜单。 我只是在我的页面中获取上述原始文本。 如何通过浏览器将此字符串转换为HTML。 请帮忙 这是导航类 class NavigationMenu options[:method]|| :get)) raise “Unrecognised path #{path}, are you sure it’s in routes.rb?” end @items < (@params[:controller] == route[:controller] && @params[:action] == route[:action])? ‘active’ : nil)) end def output return ” if @items.blank? content_tag(:ul, @items.join(“\n”), […]

单击链接在Rails中打开弹出窗口

我想点击“链接”打开一个弹出窗口,然后在那里显示一些数据并关闭它。 我正在使用’link_to’来创建’link’。 代码部分看起来像: ‘aaa’, :action=> ‘xyz_links’, ……. %>