Tag: ruby在轨道 3

从Rails 3升级到Rails 3.1

你如何从Rails 3升级到Rails 3.1 beta?

如何重命名轨4应用程序?

rails plugin install git://github.com/get/Rename.git将允许我们只重新命名轨道3应用程序 有没有任何gem可以重命名Rails 4应用程序。 如果没有,build议我更好的重命名方式。

Ruby on Rails路线 – 获得和匹配的区别

有什么区别呢? 匹配示例: match 'photos/show' => 'photos#show' 示例获取: get 'photos/show' 这两个都不可能达到照片/显示url,并使用照片控制器中的显示操作? 谢谢

钢轨捆绑安装生产只

道歉,如果这是一个RTFMtypes的问题,但我还是新的rails / ruby​​ / bundler,有点困惑。 在我们的config/application.rb文件中有这个捆绑器段: if defined?(Bundler) # If you precompile assets before deploying to production, use this line Bundler.require(*Rails.groups(:assets => %w(development test))) # If you want your assets lazily compiled in production, use this line # Bundler.require(:default, :assets, Rails.env) end 在我们的Gemfile我们使用不同的组,例如 group :development, :test do gem "rspec-rails", ">= 2.7.0", :group => [:development, :test] […]

Rails 3:如何创build一个新的嵌套资源?

由于它没有实现评论控制器的“新”动作,因此入门Rails指南对这部分有些迷惑。 在我的应用程序中,我有一个有许多章节的书籍模型: class Book < ActiveRecord::Base has_many :chapters end class Chapter < ActiveRecord::Base belongs_to :book end 在我的路线文件中: resources :books do resources :chapters end 现在我要实现章节控制器的“新”动作: class ChaptersController < ApplicationController respond_to :html, :xml, :json # /books/1/chapters/new def new @chapter = # this is where I'm stuck respond_with(@chapter) end 什么是正确的方法来做到这一点? 另外,视图脚本(表单)应该是什么样的?

使用Rails的form_for,但在<form>元素上设置自定义类,属性?

form_for似乎忽略任何“额外的”属性,比如在第二个参数中作为options传递的data-foo属性或class 。 = form_for @user, {:url => 'foo', :class => 'x', 'data-bar' => 'baz' } do |f| # … 输出是一个没有x类或data-bar属性的<form>标记。 什么是修复? 或者,我怎样才能不使用form_for抓住一个FormBuilder实例?

Ruby on Rails 3无法通过OSX上的套接字“/tmp/mysql.sock”连接到本地MySQL服务器

我有一个标准的Rails3环境,RVM 1.2.9,Rails 3.0.5,Ruby 1.9.2p180,MySQL2 Gem 0.2.7,mysql-5.5.10-osx10.6-x86_64 运行rake db:migrate时出现错误rake db:migrate到创build数据库是: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) config / database.yml有 development: adapter: mysql2 host: localhost username: root password: xxxx database: xxxx 肯定这是简单的我错过了。

如何在rails html.erb文件中注释行?

是一个新手入门,请让我知道的方式来评论出一条线,也注释了* .html.erb文件中的一行块。

如何在80端口上运行rails s -p80?

默认, rails s #running on 3000 port 现在我想在80端口上运行它。所以我尝试了: sudo rails -s -p80 但它抛出了一个错误: mlzboy@mlzboy-MacBook ~/my/b2c2 $ sudo rails s -p80 sudo: rails: command not found 我用rvm来安装ruby和rails。 看来rvm是用户指定的。 它不能在根中find轨道? 我也试过下面的代码: mlzboy@mlzboy-MacBook ~/my/b2c2 $ which rails /home/mlzboy/.rvm/gems/ruby-1.9.2-p0/bin/rails mlzboy@mlzboy-MacBook ~/my/b2c2 $ sudo /home/mlzboy/.rvm/gems/ruby-1.9.2-p0/bin/rails s -p80

Rails:如何获取基于控制器类名的模型类名?

class HouseBuyersController < … def my_method # How could I get here the relevant model name, ie "HouseBuyer" ? end end