ruby-on-rails-3.2

What's the “official” way to support Unicorn on Heroku and not lose logging?

左心房为你撑大大i 提交于 2019-12-06 13:12:38
问题 We switched to Unicorn, but lost all app logging on Heroku. I googled around a bit and learned Heroku's Ruby buildpack installs a plugin "rails_log_stdout" which doesn't play nice with Unicorn. My guess would be this has something to do with the forking nature of Unicorn, but I didn't confirm that. Various workarounds like https://gist.github.com/jamiew/2227268 where suggested. These strike me as dis-satisfying because they won't use the log levels defined in the Rails app or any tags, or

A quiz game on ruby on rails [closed]

一曲冷凌霜 提交于 2019-12-06 12:20:31
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . I am working on a quiz game using ruby on rails. I have created the basic authentication and other pages. Now I am starting work on creating the main game. I want to get an opinion about what method should I use i.e. create a seperate view for each question or is there a gem

Rails generators not generating the proper test templates

耗尽温柔 提交于 2019-12-06 12:13:48
My project lives here: https://github.com/jonesdeini/ICanHazSandvich I'm getting setup using minitest-rails add I can't get the generators to generate the correct test templates. from my application.rb: config.generators do |g| g.test_framework :mini_test, :spec => true, :fixture => false end even with "g.test_framework nil" I still get the same test templates generated: Output: rails g model Foo invoke active_record create db/migrate/20120827160129_create_foos.rb create app/models/foo.rb invoke test_unit create test/unit/foo_test.rb invoke factory_girl create test/factories/foos.rb Even with

Rails : How does “new” action called “create” action?

北城余情 提交于 2019-12-06 12:13:21
问题 I am following this tutorial http://guides.rubyonrails.org/v3.2.13/getting_started.html to build my rails app in version 3.2.13 . If you go to the section 6.9 you will find controller and view for creating new posts . Here I do not get how @post variable is passed from new action to create action and where is create function called ? Also , I faced the same problem while working on edit and update actions . Please guide me through this . 回答1: It's not passed to create action, it's

Hstore and Rails

久未见 提交于 2019-12-06 12:13:09
问题 I'm trying to use Hstore in a Rails 3.2.9 project using the latest version of the activerecord-postgres-hstore gem and I am having a bit of trouble using the store_accessor provided by ActiveRecord for the values in the Hstore. My model looks like this: class Person < ActiveRecord::Base serialize :data, ActiveRecord::Coders::Hstore attr_accessible :data, :name store_accessor :data, :age, :gender end When I go into the rails console here's what I get: Loading development environment (Rails 3.2

Using crc32 tweak on has_many relations in Thinking Sphinx

萝らか妹 提交于 2019-12-06 12:06:46
It's weird actually. I have two models that have has_many relation each other, here are my models #model city class City < ActiveRecord::Base belong_to :state end #model state class State < ActiveRecord::Base has_many :city end and I have state index ThinkingSphinx::Index.define 'state', :with => :active_record do indexes state_name, :sortable => true #here is the problem has "CRC32(cities.city_name)", :as => :city_name, :type => :integer end I want to use city_name as a filter. My code above doesn't work and i got an error message when run rake ts:index here is the error message ERROR: index

Rails: Sunspot text searching with model associations, using :through

这一生的挚爱 提交于 2019-12-06 12:06:11
How do I search with associations and through with sunspot? class StaticController < ApplicationController def search @search = Sunspot.search Business, Service do fulltext params[:q] paginate :per_page => 10 order_by_geodist(:location, *Geocoder.coordinates(params[:loc])) end @biz = @search.results end class Business < ActiveRecord::Base attr_accessible :name has_many :services, :through => :professionals searchable do text :name #name in business column # how to do I get the services? end end class Service < ActiveRecord::Base attr_accessible :service belongs_to :professional end class

rails: devise update user without password

廉价感情. 提交于 2019-12-06 11:54:42
I've followed the directions in devise's wiki regarding overriding update method to update user information without adding password , but I'm still getting notice saying that I can't leave password blank. I'm stuck and I need some assistance on tracking the problem down. <%= form_for(resource, :as => resource_name, :url => custom_update_user_registration_path, :html => { :method => :put }) do |f| %> <%= devise_error_messages! %> <%= f.text_field :first_name %> <%= f.text_field :last_name %> <%= f.email_field :email, :autofocus => true %> <% if devise_mapping.confirmable? && resource.pending

Rails - Show A Random Record But Not The Current

社会主义新天地 提交于 2019-12-06 11:48:06
At the end of a blog post I would like to display a teaser link to another random post. Obviously this link should be NOT a teaser for the current post itself. I figured already out how to choose a random post, but there is still the chance that the teaser link is a link to the current post. I couldn't figure out, how can I exclude this case. Here is my controller: def show @post = Post.find(params[:id]) @staff_pickrandom = Post.where(staff_pick:true).order("RANDOM()").limit(1) end I am quite new to Rails and I am still struggling with basic stuff. Sorry, if this is an easy one. Thank you so

Dynamic Select with ancestry

怎甘沉沦 提交于 2019-12-06 11:39:02
问题 My application using ancestry gem. class Location < ActiveRecord::Base has_ancestry :cache_depth => true has_many :posts end class User < ActiveRecord::Base belongs_to :location end I created some random Location, Alaska California Los Angeles Fresno Cincotta (Fresno) Hammond (Fresno) Melvin (Fresno) My question if user sign up form if User select California, display child Los Angles and Fresno, after select Fresno then display it's child. I got javascript tutorial for Dropdown list http:/