ruby-on-rails-3

What in nginx determines what goes to rails and what is served directly?

风格不统一 提交于 2019-12-24 16:05:24
问题 I have a nginx + thin + Rails 3.2 setup. Currently I am trying to setup nginx so it can serve cached pages directly. However nginx still pass *.html request to Rails in the following nginx configuration files. The html files exists in public folder, and nginx does find them, just that they are still passed to Rails. upstream site { server unix:/home/site/deploy/site/shared/pids/thin.0.sock; } server { listen 80; server_name www.example.com; rewrite ^(/.*) http://example.com$1 permanent; } #

How to drop a primary key?

痴心易碎 提交于 2019-12-24 15:58:54
问题 So, I'd like to drop the current primary key on my users table.. I think it's on the email column. And add a primary key to the uid column instead to get my omniauth working. schema.rb snippit create_table "users", force: true do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" t.integer "sign_in_count", default: 0 t.datetime "current_sign

Debugging Rubymine - only debug project files?

久未见 提交于 2019-12-24 15:52:27
问题 I've been using RubyMine and like it a lot so far. Is there any way to only step through my project files? When I click "Step Over" or "Step Out" I'm taken into framework and library files, which I don't need to look at. 回答1: RubyMine doesn't currently have this feature; here is the relevant enhancement request. 来源: https://stackoverflow.com/questions/7732660/debugging-rubymine-only-debug-project-files

How to pass foreign key attributes down through a nested form in Rails 3

社会主义新天地 提交于 2019-12-24 15:25:11
问题 I have three models: class Client < ActiveRecord::Base has_many :balancesheets has_many :investment_assets, :through => :balancesheets class Balancesheet < ActiveRecord::Base belongs_to :client has_many :investment_assets, :dependent => :destroy accepts_nested_attributes_for :investment_assets, :allow_destroy => true class InvestmentAsset < ActiveRecord::Base belongs_to :balancesheet belongs_to :client I have two questions that have to do with the foreign key client_id. First, when I create a

How to fix “uninitialized constant SampleApp”

Deadly 提交于 2019-12-24 15:18:48
问题 I'm trying to run rails server and I'm seeing something like this: C:\Users\Mama i Tata>cd c:/rails_project/my_app c:\rails_project\my_app>rails s => Booting WEBrick => Rails 3.2.6 application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server Exiting c:/rails_project/my_app/config/routes.rb:1:in `<top (required)>': uninitialized constant SampleApp (NameError) from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.6/lib/rails/applic ation

Rails 3 - Validation for Time existence

谁说胖子不能爱 提交于 2019-12-24 15:13:28
问题 I have a model with a Time attribute. I want to check that time can not be empty (better choice probably would be to check that input is time but i have no ideas how to deal with that). I tried this validation: # id :integer not null, primary key # school_class_id :integer # meeting_time :time class Meeting < ActiveRecord::Base validates :meeting_time, :presence => { :message => "can't be empty!" } end Then i tried to check this in spec and this fails (empty time is ok but it should not be).

carrierwave image not loading into source code

 ̄綄美尐妖づ 提交于 2019-12-24 15:05:59
问题 Not sure what I'm doing wrong on this one. I've followed the Rails Cast for Carrierwave but am having a strange bug where the image isn't showing at all - the (HTML) source code is showing the image tag but nothing inside it. Portfolio Model code: class Portfolio < ActiveRecord::Base validates :title, :content, presence: true mount_uploader :feature_image, FeatureImageUploader end Feature Image Uploader code: class FeatureImageUploader < CarrierWave::Uploader::Base storage :file def store_dir

Difference between click_on and click_link?

纵饮孤独 提交于 2019-12-24 15:01:17
问题 I am writing request specs and I am using poltergeist-1.0.2 and capybara-1.1.2. I have the following code: login_as @user, 'Test1234!' click_on 'Virtual Terminal' the login has flash message that shows to the user that he is successfully logged in. When I am using click_link, the spec fails because Capybara can't find element 'Virtual Terminal' but when I am using click_on everything passes. 'Virtual Terminal' is not a button, it is a link. What is the difference between click_on and click

Ruby on Rails: How to assign a hard value to a variable?

亡梦爱人 提交于 2019-12-24 14:53:18
问题 I am using multiple redirects, and I would like to redirect from A->B->C->A. So in B, I save path A as @previouspage = request.referer and so @previouspage = A at this point, but when I call @previouspage in C, it doesn't bring the hard value saved in B, but finds its own relative request.referer, which is B. So in C, @previouspage = B (because I think variables in Ruby are soft-links) How would I just save whatever the value of request.referer was at point B, and then save that URL into a

chosen-rails error chosen is not a function

心不动则不痛 提交于 2019-12-24 14:35:01
问题 I am using chosen-rails for integration of chosen.js with rails asset pipeline I have included in my Gemfile gem 'chosen-rails' then bundle install in my application.js I have //= require jquery //= require jquery_ujs //= require chosen-jquery //= require_self in my application.css I have *= require chosen The page loads the js as required /assets/jquery.js?body=1 /assets/jquery_ujs.js?body=1 /assets/lib/select-parser.js?body=1 /assets/chosen.jquery.js?body=1 But I I try to use the function