ruby-on-rails-3

From db to css file?

谁说胖子不能爱 提交于 2019-12-24 02:16:53
问题 I have a small set of css items in a db table that I need to turn into a css file to be included on a page. How can I do this in Rails3? Is there a way I can call this directly from a stylesheet_link tag? Do I need to go through some ruby to open a file and output it in some directory first? Do I do this in a controller? The css is actually its own model associated to the item using the css. I do not know and looking for a solution found little yet, so asking here. EDIT: Simple when looked at

Rails joins query

眉间皱痕 提交于 2019-12-24 02:14:35
问题 I have three models Tag => :id , :name Tagging => :id , :tag_id , :post_id Post => :id , :summary I know the id of the tag. I would like to query for all of the posts that have a specific tag_id , through the Taggings model. Something like @post = Post.joins(:taggings).where(:tag_id => 17) but this doesn't work because it is looking for the tag_id in the Post model and not the Tagging model. I'm not sure how to do this. 回答1: Using the .where format you can pass a string like .where("taggings

OR query matching nil or “” with Mongoid still matches “”?

无人久伴 提交于 2019-12-24 01:59:36
问题 I'm trying to write a query for an embedded Mongoid::Document which finds any record where the "address" field is neither nil nor "". Using a combination of the MongoDB documentation, this issue in the Mongoid bug reports, and the Mongoid documentation, I think that something like this should work: scope :with_address, where("$or" => [{:address => {"$ne" => nil}}, {:address => {"$ne" => ""}}]) When I run this, the selector looks ok: 1.9.2p290 :002 > report.document.records.with_address => #

Rails - problem installing Spree

拥有回忆 提交于 2019-12-24 01:44:27
问题 I'm having a problem installing Spree in a Rails app. when I run gem 'spree' (as per the instructions on http://spreecommerce.com/documentation/getting_started.html) I get the following error: ERROR: While executing gem ... (RuntimeError) Unknown command spree I have the following Spree gems installed: gem list spree *** LOCAL GEMS *** spree (0.30.1) spree_api (0.30.1) spree_auth (0.30.1) spree_core (0.30.1) spree_dash (0.30.1) spree_promo (0.30.1) spree_sample (0.30.1) when I installed the

rspec test using regular database not test database

家住魔仙堡 提交于 2019-12-24 01:43:41
问题 I am using Rspec, webrat, selenium rc for tests. I am trying to do integration test with selenium and rspec. I just looked in my development database and learned that my integration tests are using my development database and not my test database. How an I configure rails and rspec and selenium to use my test database. All my other tests seem to be using my test database. 回答1: Do you have a line like ENV["RAILS_ENV"] ||= 'test' in your spec_helper.rb? does it force the use of the test db if

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension

£可爱£侵袭症+ 提交于 2019-12-24 01:43:08
问题 To provide some background - I've just downloaded a Git Repo from GitHub, for a friends app and I am attempting to launch it from my Mac ('rails s'). However, I am being hit with the following error // see below // when running 'bundle install'. It seems as if the 'pg' (postgreSQL) gem is having some sort of obscure installation error. Any help would be appreciated! I have tried this command to no avail: $gem install pg -- --with-pg-config= /usr/bin/pg_config/ And here is the error log:

Not able to set a current_user using Authlogic on Rails 3.0.1

微笑、不失礼 提交于 2019-12-24 01:43:01
问题 I had the official authlogic plugin running perfectly on Rails 2.3.5. I converted my application to Rails 3.0.1 and now I'm having some problems. I've included the following authlogic gem in my gemfile gem 'authlogic', :git => 'git://github.com/odorcicd/authlogic.git', :branch => 'rails3' When a user logs in, the session is saved. When calling that user session, the returned value is nil. UserSession.find returns a nil value so I'm not able to assign a current_user. sessions_controller.rb def

Not able to set a current_user using Authlogic on Rails 3.0.1

梦想的初衷 提交于 2019-12-24 01:42:04
问题 I had the official authlogic plugin running perfectly on Rails 2.3.5. I converted my application to Rails 3.0.1 and now I'm having some problems. I've included the following authlogic gem in my gemfile gem 'authlogic', :git => 'git://github.com/odorcicd/authlogic.git', :branch => 'rails3' When a user logs in, the session is saved. When calling that user session, the returned value is nil. UserSession.find returns a nil value so I'm not able to assign a current_user. sessions_controller.rb def

how to call controller action in ajax url

泄露秘密 提交于 2019-12-24 01:36:06
问题 I want to call the controller method in ajax url to dynamically populate the dropdown based on value from another dropdown. The value I am getting is string, when I call this method using ajax url it always refers to 'show' method. My ajax call $('#users').change(function() { url: '/users/update_groups', data: {name: $(this).val()}, success: function (data) { alert(data); } }); In my users_controller.rb def update_groups user_name # returns list of groups end How to call this method using

How to get rvm running inside fcgi?

不想你离开。 提交于 2019-12-24 01:25:17
问题 I had a rails 2.3 application running on apache + fcgi, and I am migrating it to rails 3.1 + rvm (+ apache + fcgi). I am now blocked at fcgi <-> rvm. I tried putting #!/usr/local/bin/rvm 1.9.2@rails31 exec ruby inside my public/dispatch.fcgi . Running /usr/local/bin/rvm use 1.9.2@rails31 exec ruby /some_path/current/public/dispatch.fcgi from my command line works fine, but the apache log shows: ERROR: Unrecognized command line argument(s): '/some_path/current/public/dispatch.fcgi ' ( see: