ruby-on-rails-4.2

Why is there a wrong number of arguments error when using redirect_to in Rails 4.2?

自作多情 提交于 2019-11-29 17:37:21
问题 In the Rails 4.1.1 version of an app, I have the following create method in articles_controller: def create @article = Article.new(article_params) authorize @article if @article.save flash[:notice] = "Successfully created article." redirect_to edit_article_path(@article) else render :new end end However, after updating to Rails 4.2 the following error occurs when the redirect is attempted: wrong number of arguments (2 for 1) Why does this error occur and how can it be resolved? 回答1: The issue

Why does Rails 4.2 + responders keeps telling me to add responders to the Gemfile?

断了今生、忘了曾经 提交于 2019-11-29 10:43:10
I'm upgrading a Rails 4.1.8 app (also using rails-api ~> 0.3.1) to 4.2.0.rc2 and would like to retain the respond_with functionality. I've added responders to the Gemfile, but when I bin/rake spec , I get: /Users/sloveless/.gem/ruby/2.1.0/gems/actionpack-4.2.0.rc2/lib/action_controller/metal/mime_responds.rb:10:in `respond_to': The controller-level `respond_to' feature has been extracted to the `responders` gem. Add it to your Gemfile to continue using this feature: (NoMethodError) gem 'responders', '~> 2.0' Consult the Rails upgrade guide for details. from /Users/sloveless/Development

How to make Rails 4.2 work with Postgres Jsonb?

大憨熊 提交于 2019-11-29 10:24:25
I've seen a few blog posts claiming that rails 4.2 added support for the new Jsonb data type in Postgres 4.2. However, googling gets me zero results on how to actually use the datatype. Since I'm not depending on key order and I would like my application to be fast, I would very much like to use Jsonb instead of json in one of my models. Was it actually added in 4.2, and, if so, how do you use it? It's part of the not yet released version of Rails 4.2 (currently 4.2.0.rc3). To use the datatype, specify the jsonb type when creating a table: create_table :users do |t| t.jsonb :extra_info end or

No such file or directory @ rb_sysopen - public/receipts/416981.pdf

拜拜、爱过 提交于 2019-11-29 06:15:36
Below on line no. 2, I am getting this error: Errno::ENOENT in OrdersController#print def generate_receipt(filename = nil, current_user = nil) filename ||= "public/receipts/#{id}.pdf" Prawn::Document.generate(filename, :page_layout => :portrait, :page_size => 'LETTER', :skip_page_creation => false, :top_margin => 50, :left_margin => 50)do |pdf| pdf_receipt_data(pdf, false, 'store_front', current_user) pdf.number_pages "<page> of <total>", :at => [0, 0] end end On my localhost this code is working but on testing env I am getting this error. I am using rails 4.2. Please help me out. After

rails server cannot start; getaddrinfo: nodename nor servname provided, or not known (SocketError)

旧巷老猫 提交于 2019-11-29 02:37:25
I have not found a solution to the problem, however someone did already ask about the same problem a few days ago - ( Rails Server Keeps Exiting (SocketError) ) After I start a rails server the system returns some error I cannot understand. To install Ruby on Rails on my mac I did everything as listed on http://railsapps.github.io/installrubyonrails-mac.html here is my terminal response: $ rails server => Booting WEBrick => Rails 4.2.0 application starting in development on http://localhost:3000 => Run `rails server -h` for more startup options => Ctrl-C to shutdown server [2015-02-28 02:14:46

Add nullable foreign key in Rails

南楼画角 提交于 2019-11-28 22:23:53
Referencing to Rails 4.2 add_foreign_key support: # add a foreign key to `articles.author_id` referencing `authors.id` add_foreign_key :articles, :authors How to create a nullable foreign key constraint, to allow the situation, where articles.author_id can be sometimes null? There is nothing in the guide that implies add_foreign_key would make the corresponding foreign field "NOT NULL" or required. add_foreign_key simply adds a foreign key constraint whether the field is required or not (in your case author_id in articles ). Did you get an error when you tried this in your migration? Here's

Rails 4.2 Server port forwarding on Vagrant does not work

末鹿安然 提交于 2019-11-28 15:49:45
问题 I have a Vagrant VM with Rails installed with a sample app. The VM is configured to forward the port 3000 (of Rails Webrick server) to my host 3000 port. config.vm.network "forwarded_port", guest: 3000, host: 3000 Everything is configured as seen in a lot of examples. But, when I try to access http://localhost:3000 nothing happens. I've also tried to forward to other random ports like 8081, 25600, without success. Doing a curl request also does not get anything (just a Connection reset by the

How to make Rails 4.2 work with Postgres Jsonb?

穿精又带淫゛_ 提交于 2019-11-28 03:37:58
问题 I've seen a few blog posts claiming that rails 4.2 added support for the new Jsonb data type in Postgres 4.2. However, googling gets me zero results on how to actually use the datatype. Since I'm not depending on key order and I would like my application to be fast, I would very much like to use Jsonb instead of json in one of my models. Was it actually added in 4.2, and, if so, how do you use it? 回答1: It's part of the not yet released version of Rails 4.2 (currently 4.2.0.rc3). To use the

Rails 4 - Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded

混江龙づ霸主 提交于 2019-11-27 17:05:29
In my gemfile I have: gem 'mysql2' My database.yml is as follows: default: &default adapter: mysql2 database: <%= ENV['db_name'] %> username: <%= ENV['db_user'] %> password: <%= ENV['db_pass'] %> host: <%= ENV['db_host'] %> pool: 32 socket: <%= ENV['socket'] %> development: <<: *default production: <<: *default I've run both bundle update and bundle install and my Gemfile.lock shows mysql2. However when I run rake db:migrate I get this on both my computer and on the staging server: myproject.com(master)$ rake db:migrate WARNING: Use strings for Figaro configuration. 10000012508 was converted

rails server cannot start; getaddrinfo: nodename nor servname provided, or not known (SocketError)

坚强是说给别人听的谎言 提交于 2019-11-27 16:57:17
问题 I have not found a solution to the problem, however someone did already ask about the same problem a few days ago - (Rails Server Keeps Exiting (SocketError)) After I start a rails server the system returns some error I cannot understand. To install Ruby on Rails on my mac I did everything as listed on http://railsapps.github.io/installrubyonrails-mac.html here is my terminal response: $ rails server => Booting WEBrick => Rails 4.2.0 application starting in development on http://localhost