ruby-on-rails-3

'EOFError: end of file reached' on HEROKU while posting UTF-8 via SSL

╄→гoц情女王★ 提交于 2019-12-23 08:47:18
问题 I've got strange bug on heroku. To reproduce it I have to make big (over few KB) HTTPS POST with any UTF-8 characters in request body. Here is an example: require "net/https" require "uri" #Accutally I've ecountered this bug while posting to another server url = URI.parse("https://api.heroku.com/myapps") #It's Ukrainian 'oiced velar plosive G' letter payload = "ґ"*10000 request = Net::HTTP::Post.new(url.path) request.body = payload http = Net::HTTP.new(url.host, url.port) http.use_ssl = true

rails console test loading development environment

五迷三道 提交于 2019-12-23 08:46:09
问题 I have a problem where rails console test results in Loading development environment (Rails 3.1.0) I suspect it's a RAILS_ENV problem because doing RAILS_ENV=test rails console results in Loading test environment (Rails 3.1.0) Any suggestions? Thanks. 回答1: Yes, you must specify RAILS_ENV or use rails console [environment] . 回答2: Is environment variable RAILS_ENV already set (in your command line environment)? Ideally, rails console test should set RAILS_ENV to 'test' and disregard its value

rails console test loading development environment

元气小坏坏 提交于 2019-12-23 08:44:41
问题 I have a problem where rails console test results in Loading development environment (Rails 3.1.0) I suspect it's a RAILS_ENV problem because doing RAILS_ENV=test rails console results in Loading test environment (Rails 3.1.0) Any suggestions? Thanks. 回答1: Yes, you must specify RAILS_ENV or use rails console [environment] . 回答2: Is environment variable RAILS_ENV already set (in your command line environment)? Ideally, rails console test should set RAILS_ENV to 'test' and disregard its value

What is the Rails (>=3.1) generator syntax for creating a subclass model / scaffold?

梦想的初衷 提交于 2019-12-23 08:36:32
问题 What is the command line syntax for generating a subclass model or scaffold in Rails? rails g model Mysubclass my_field:string .... How do I specify the parent class? 回答1: You can use "--parent=ParentClass". Example: 1) Create a parent class "User". rails g scaffold User login:string 2) Create a child class "Teacher". rails g scaffold Teacher url:string --parent=User But remember: you still need to create migrations(adding columns in datatables) and change views(adding fields in forms). 回答2:

I am using Devise, the password change is redirecting to home page, how to keep it on /users/edit?

霸气de小男生 提交于 2019-12-23 08:25:09
问题 I am using devise and the views file is /devise/registrations/edit.html.erb (I have not made any changes to it): <div><%= f.label :password %> <%= f.password_field :password, :autocomplete => "off" %></div> <div><%= f.label :password_confirmation %> <%= f.password_field :password_confirmation %></div> <% if f.object.encrypted_password.present? %> <div><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br /> <%= f.password_field :current_password %>

rails 3.2.0 and heroku

做~自己de王妃 提交于 2019-12-23 07:57:57
问题 Hey Guys I'm having some troubles with rails 3.2.0 & ruby 1.9.3, I only created a new app with rails new command and I'm trying to deploy to heroku. I'm having the following app error: An error occurred in the application and your page could not be served. Please try again in a few moments. If you are the application owner, check your logs for details. After run heroku logs I get the following error: Could not find activemodel-3.2.0 in any of the sources Thanks in advance!!!! GemFile source

Heroku app crashes, logs say “No such file to load — nokogiri (LoadError)”

烈酒焚心 提交于 2019-12-23 07:40:30
问题 I had a working app, added Nokogiri, to parse some xml, runs fine locally. My Gemfile includes: gem 'nokogiri' I ran bundle install and verified my Gemfile.lock includes DEPENDENCIES ... nokogiri In my controller class I added (didnt thinkI had to but got an error locally if I didnt): class MydealController < ApplicationController require 'rubygems' require 'open-uri' require 'nokogiri' when I use my browser to get the url in MydealController that uses nokogiri doc = Nokogiri::XML(getresult)

Remove password confirmation; devise

落爺英雄遲暮 提交于 2019-12-23 07:39:20
问题 I am using devise for authentication in my Rails 3.2.6 app. I had password confirmation first but now I want to remove it. How to go about that? 回答1: You just need to remove the password_confirmation field from your form. More info in this answer. 来源: https://stackoverflow.com/questions/11641901/remove-password-confirmation-devise

How to enforce unique embedded document in mongoid

吃可爱长大的小学妹 提交于 2019-12-23 07:38:32
问题 I have the following model class Person include Mongoid::Document embeds_many :tasks end class Task include Mongoid::Document embedded_in :commit, :inverse_of => :tasks field :name end How can I ensure the following? person.tasks.create :name => "create facebook killer" person.tasks.create :name => "create facebook killer" person.tasks.count == 1 different_person.tasks.create :name => "create facebook killer" person.tasks.count == 1 different_person.tasks.count == 1 i.e. task names are unique

Ruby/Rails - Open a URL From The Controller In New Window

折月煮酒 提交于 2019-12-23 07:30:21
问题 I'm in my applications controller and I have a url string. How do I tell the app to open the url in the browser in a new window. Is there a way to set the target to blank? For example def link @url = 'www.google.com' ****??? Open @url ?? *** with target blank? end 回答1: This is not possible to do directly from the controller. Using redirect_to @url has the effect of opening an URL in the same "window", as it simply sends a HTTP redirect instruction back to the browser. redirect_to is not