ruby-on-rails-3.1

OmniAuth Single Sign On with Devise, invalid_credentials

£可爱£侵袭症+ 提交于 2019-11-29 22:07:55
问题 I have 3 web apps - A, B and C. App A contains the user database. If accessing App B and App C, I would like the user to be redirected to App A to be authenticated, and then be returned back to whichever app they tried to access. At the same time, they should be logged in to all apps. Unless anyone has a better solution, I have gone with an OmniAuth/Devise combo solution as described in this blog post. I have forked and updated to Rais 3.1.2 a sample App A and a sample app B/C. App A -

Rails 3.1: Determine if asset exists

陌路散爱 提交于 2019-11-29 22:05:41
Is there a built-in way to determine if an asset exists without resorting to File.exists?(File.join(Rails.root, "foo", "bar", "baz")) and that looks through the asset paths. My app goes and fetches images from a remote server on a Resque queue; until we have the image downloaded I want to serve a placeholder image. Currently I'm using File.exists ... but this means hard-coding a path, which sucks, or looking through the configured asset paths. It seems like this should be there already, but I can't find it in the docs. Joe Van Dyk Given an image in app/assets/images/lolshirts/theme/bg-header

rails 3.1 asset pipeline css caching in development

限于喜欢 提交于 2019-11-29 21:19:50
I'm a bit confused as it seems like the application.css is including itself twice, once when it lists the resources from the manifest and then a cache of that. So when I delete an individual file it still seems to stay alive inside the application.css file. application.css (source) /* *= require twitter/bootstrap *= require_self *= require_tree ./common *= require_tree ./helpers */ Which works as expected and outputs in dev mode all the relevant individual files development.rb # Do not compress assets config.assets.compress = false # Expands the lines which load the assets config.assets.debug

Rails: How to find_by a field containing a certain string

怎甘沉沦 提交于 2019-11-29 21:18:29
I have a model named Topic, that has a name as a field. So say I have a term I'm searching for, apple. If I do a Topic.find_by_name("apple") I get a record back with the name apple. That's good -- but how do I change find_by_name so that it can find "apple juice" as well as "apple" -- basically, find names that contain the original query or exactly match the original query? Edit: Thanks for all the response. I guess I should've been a little more clear earlier, but what if I want to find by a variable name (obviously I'm not going to want to find by the name "apple" everytime :) )? How do I

“Uninitialized constant” error when including a module

拟墨画扇 提交于 2019-11-29 20:51:29
I am trying to reference an association extension but it errors with: NameError (uninitialized constant User::ListerExtension): app/models/user.rb:2:in `<class:User>' Here is my implementation: app/models/user.rb class User < ActiveRecord::Base include ListerExtension has_and_belongs_to_many :roles, :uniq => true, :extend => Lister lib/lister.rb module ListerExtension def lister self.map(&:to_s).join(', ') end end I am using Rails v3.1.3. Xavier Holt Andrew Marshall has an excellent point about the auto-load setup (see the question he links for more on that), but also: Because you named your

Rails 3.1 serving images from vendor/assets/images

我怕爱的太早我们不能终老 提交于 2019-11-29 20:15:45
I am trying to put some external images (used by a jQuery plugin) to vendor/assets/images in my Rails 3.1 app. Problem is that when I try something like: <%= image_tag "ui-bg_flat_75_ffffff_40x100.png" %> I get an error: No route matches [GET] "/assets/ui-bg_flat_75_ffffff_40x100.png" I checked my Rails.application.config.assets.paths and it list these dirs: ..../app/assets/images ..../app/assets/javascripts ..../app/assets/stylesheets ..../vendor/assets/images ..../vendor/assets/stylesheets ..../.rvm/gems/ruby-1.9.2-p180@mygems/gems/jquery-rails-1.0.9/vendor/assets/javascripts As you can see

Upgrading from Rails 3 to Rails 3.1 [closed]

十年热恋 提交于 2019-11-29 19:51:00
How do you upgrade from Rails 3 to Rails 3.1 beta? This is what worked for me when updating an existing rails 3.0.8 project. Your mileage may vary... Update the rails version specified in my Gemfile to use the latest release candidate: gem 'rails', '3.1.0.rc4’ Update the bundle: bundle update Then update the project with the rake command: rake rails:update After cherry picking though the change conflicts I ran all my tests and they passed (yay!). I restarted the server and everything seems good so far. However, this is not using the new asset pipeline yet. By that I mean the javascript and css

Rails 3.1 - Pushing to Heroku - Errors installing postgres adapter?

时间秒杀一切 提交于 2019-11-29 19:44:05
I just upgraded to Rails 3.1 and the first app i've tried to deploy to Heroku has encountered a problem relating to Postgres adapter. I'm able to push the app to heroku but then when i try to migrate the database i get the following error: heroku rake db:migrate rake aborted! Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.) Tasks: TOP => db:migrate => db:load_config (See full trace by running task with --trace) when I try their suggested install i get: ERROR: Could not find a valid gem 'activerecord

Ruby on Rails: How can I revert a migration with rake db:migrate?

廉价感情. 提交于 2019-11-29 19:04:23
After installing devise MODEL User i got this. class DeviseCreateUsers < ActiveRecord::Migration def self.up create_table(:users) do |t| t.database_authenticatable :null => false t.recoverable t.rememberable t.trackable # t.encryptable # t.confirmable # t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both # t.token_authenticatable t.timestamps end add_index :users, :email, :unique => true add_index :users, :reset_password_token, :unique => true # add_index :users, :confirmation_token, :unique => true # add_index :users, :unlock_token, :unique => true # add_index :users,

Devise install from existing model/database

和自甴很熟 提交于 2019-11-29 19:03:31
问题 I am wondering how can i add devise to an existing database with a different user. Here I already have a customer model define and I want to change to allow devise to work on it. I have created a new migration and inserted the code has follow class AddDeviseToCustomer < ActiveRecord::Migration def change change_table :customers do |t| #t.database_authenticatable t.string :encrypted_password, :null => false, :default => '', :limit => 128 t.confirmable t.recoverable t.rememberable t.trackable t