Rails

Autotest with Rspec2 in Rails 3 Can't Find Binaries

匿名 (未验证) 提交于 2019-12-03 08:30:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to get autotest back up and running after moving my project to rails 3. After upgrading to rspec 2.0.0.beta.22, I can't seem to run autotest. I get the following: bundler: command not found: c:/Ruby192/lib/ruby/gems/1.9.1/gems/rspec-core-2.0.0.beta.22/bin/rspec even though the binary does in fact exist in that location. Here is my Gemfile contents: group :development do gem 'webrat' gem 'rspec-rails', '>=2.0.0.beta.22' gem 'factory_girl_rails', '1.0' gem 'autotest' end group :test do gem 'webrat' gem 'rspec-rails', '>=2.0.0.beta

Rails Filter records of child model based upon the parent model attribute

匿名 (未验证) 提交于 2019-12-03 08:28:06
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Following are the 1-to-M models: class FotoGossip < ActiveRecord::Base has_many :uploads attr_accessible :published_at, ... end class Upload < ActiveRecord::Base belongs_to :foto_gossip end Now I want the Uploads.all with the condition :published_at NOT NULL of the corresponding upload's parent model? 回答1: Just add this to your Upload model: then you can get all the uploads with published foto_gossip like this: Upload.with_published_foto_gossip 文章来源: Rails Filter records of child model based upon the parent model attribute

Ruby on Rails - Validate a Cost

匿名 (未验证) 提交于 2019-12-03 08:28:06
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: What is the best way to validate a cost/price input by a user, validation rules below: Examples of formats allowed .23, .2, 1.23, 0.25, 5, 6.3 (maximum of two digits after decimal point) Minimum value of 0.01 Maximum value of 9.99 回答1: Check the price and verify the format #rails 3 validates :price, :format => { :with => /\A\d+(?:\.\d{0,2})?\z/ }, :numericality => {:greater_than => 0, :less_than => 10} #rails 2 validates_numericality_of :price, :greater_than => 0, :less_than => 10 validates_format_of :price, :with => /\A\d+(?:\.\d{0,2})?\z/

undefined method `sass' for #&lt;Rails::Application::Configuration:0x1cf3338&gt; on Staging

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am trying to deploy my aplication on server and using staging environment . But its keep giving me this error on staging environment . undefined method `sass' for #Rails::Application::Configuration:0x1cf3338 On my development environment local its working fine. In my application i am using the compass and susy framework , my Gemfile look like this https://gist.github.com/2003755 I am trying it to configure this from past 2 days , but still not find a way to make it work . Previously this configuration is working fine . Suddenly

f.error_messages in Rails 3.0

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Rails 3.0 deprecated f.error_messages and now requires a plugin to work correctly - I however want to learn how to display error messages the (new) native way. I am following the getting started guide , which uses the deprecated method when implementing the comments form. For example: Add a comment : Here is the correct way to do it (as generated by the scaffold): prohibited this post from being saved : . . . I understand that I use the @post variable in the latter example, but what variable do I reference in the former to get the

Validating :inclusion in rails based on parent Model&#039;s attribute value

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have two models Project and 'Task` where project has_many tasks and task belongs to project Now in my Task model I am doing validation on a field using attributes in the project validates :effort, :inclusion => 1..(project.effort) This results in an error method_missing: undefined method project Question is, how can I validate a child attribute (Task.effort) based on a parent's attribute's value (Project.effort) in Rails 3? 回答1: I ended up doing the validation in a callback and throwing an exception if it is not valid. The only drawback is

Rails error “NoMethodError” - My first ruby app

匿名 (未验证) 提交于 2019-12-03 07:36:14
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am absolutely and totally new to rails, so the answer is probably very simple. Here goes: My page is generating this error NoMethodError in Tasks#new Showing app/views/tasks/new.erb where line #3 raised: undefined method `tasks_path' for # Here is the view: <% form_for(@task) do |f| %> <%= f.error_messages %> <%= f.label :description %>: <%= f.text_field :description %><br /> <%= f.label :priority %>: <%= collection_select(:news, :priority_id, Priority.find(:all), :id, :description) %><br /> <%= f.submit "Add Task" %> <% end %> The

Sending binary data to (Rails) RESTful endpoint via JSON/XML?

匿名 (未验证) 提交于 2019-12-03 07:36:14
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am currently putting together a rails-based web application which will only serve and receive data via json and xml. However, some requirements contain the ability to upload binary data (images). Now to my understanding JSON is not entirely meant for that... but how do you in general tackle the problem of receiving binary files/data over those two entrypoints to your application? 回答1: I suggest encoding the binary data in something like base64. This would make it safe to use in XML or JSON format. http://en.wikipedia.org/wiki/Base64 回答2:

gitlab 邮件设置

可紊 提交于 2019-12-03 04:49:07
这个我没做实验。 视屏里面说的 126的 邮箱限制少点。 建议用126的 邮箱。 参考视屏 jenkins+gitlab+插件\1\7(07-gitlab备份恢复) 最后的一点部分。 需要在配置里面替换这些内容 gitlab_rails['time_zone'] = 'Asia/Shanghai' gitlab_rails['gitlab_email_enabled'] = true gitlab_rails['gitlab_email_from'] = 'guohongze@126.com' # 本人的邮件 gitlab_rails['gitlab_email_display_name'] = 'gitlab' gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.126.com" # 邮箱服务器。 126的不用改 gitlab_rails['smtp_port'] = 25 gitlab_rails['smtp_user_name'] = "guohongze" # 用户 gitlab_rails['smtp_password'] = "your_password" # 密码 gitlab_rails['smtp_domain'] = "126.com" gitlab_rails[

Facebook SDK and rails 4 Turbolinks

匿名 (未验证) 提交于 2019-12-03 03:12:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm having a hard time trying to load fast the javascript Facebook SDK into my rails 4 application. Is there a good way to make it work correctly with turbolinks? if i add this code on my JS application assets. It's not working properly due to turbolinks: <div id="fb-root"></div> <script> window.fbAsyncInit = function() { // init the FB JS SDK FB.init({ appId : 'YOUR_APP_ID', // App ID from the app dashboard channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel file for x-domain comms status : true, // Check Facebook Login status