ruby-on-rails-3.1

Rake error :warning: already initialized constant MAJOR [duplicate]

社会主义新天地 提交于 2019-12-03 07:12:43
Possible Duplicate: Problem to run comand rake yulong@ubuntu:~/depotnew$ rake db:migrate /home/yulong/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/version.rb:4: warning: already initialized constant MAJOR /home/yulong/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/version.rb:5: warning: already initialized constant MINOR /home/yulong/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/version.rb:6: warning: already initialized constant BUILD /home/yulong/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/version.rb:3: warning: already initialized constant NUMBERS /home/yulong/.rvm

multiple database connections with has_many through

给你一囗甜甜゛ 提交于 2019-12-03 07:00:06
How can I make a has_many through work with multiple database connections? I have a database named "master" that holds the location information. That is updated from a separate application. Users can have access to many locations, but all the other models are located in another database named "budget". Here are how the models are setup. # place.rb class Place < ActiveRecord::Base belongs_to :user belongs_to :location end # user.rb class User < ActiveRecord::Base has_many :locations, :through => :places has_many :places end # location.rb class Location < ActiveRecord::Base establish_connection

Carry Sass variables through the Assets Pipeline, Rails 3.1 rc1

安稳与你 提交于 2019-12-03 06:59:32
问题 I recently branched one of my Rails 3.0 projects with the 3.1 rc1 to try the new assets pipeline. I've been using Sass in the project before going 3.1 so I've been setting up some variables and functions in a separate configure file and let all my other sass files import that one file at the first line. This has been working out great to not repeat some color codes and general geometry through in the stylesheets. Problem is now with the new Assets Pipeline is that as I've understood it

Configure session_store.rb to handle staging and production?

拟墨画扇 提交于 2019-12-03 06:58:04
I have a staging and a production environment on my rails 3.1rc6 app which uses subdomains. I've bought and configured different domain names for these environments, because the default something-something.herokuapp.com doesn't play nicely with subdomains. When I set session_store.rb to this for one environment, everything works fine: AppName::Application.config.session_store :cookie_store, :key => '_sample_app_session' , :domain => '.mystagingdomain.co.uk' But I can't seem to add in a conditional to allow for the environment-specific domain names. I've tried AppName::Application.config

How to change case of interpolated variables in Rails locale file?

假如想象 提交于 2019-12-03 06:47:56
Using Rails 3.1.3 with Ruby 1.9.3p0. I've discovered that by default, Rails does not use sentence case for form buttons. For example, instead of an "Update user" button, it generates an "Update User" button. The button names come from the ActionView locale file . Is there a way to create a default that downcases the model name? This is not covered in the Ruby on Rails Guides i18n section on Interpolation so maybe it is not possible. The following doesn't work: en: helpers: submit: update: 'Update %{model}.downcase' In general, I'd be glad to find a reference for the syntax of the locale YAML

Generate Thumbnail From pdf in rails paperclip

混江龙づ霸主 提交于 2019-12-03 06:38:36
How can I generate the first page of a pdf as a thumbnail in paperclip? I tried a lot but it's not working has_attached_file :book_url, :styles => { :thumb => "100x100#", :small => "150x150>", :medium => "200x200" } This is giving the name of the pdf as a link but it's not giving the first page of the pdf <%= link_to 'My PDF', @book.book_url.url %> Tadas' answer is right, but for those who need more context, you can do something like this: The model below only creates thumbnails for certain kinds of files (e.g. it doesn't make thumbnails of audio files), but does make thumbnails for pdfs,

Ruby on Rails 3.1 Blog Engines

喜欢而已 提交于 2019-12-03 06:13:55
I see a lot of people asking about Blog Engines, but most of the questions & answers are rather old. Or if they aren't old most of the projects are old. I'm wondering if anyone knows of any Blog Engines that currently support Rails 3.1 or are at least being actively developed to support Rails 3.1. I would also be interested in seeing any sample applications or blog posts written for Rails 3.1 Blogs. I am going to be adding a blog to one of my websites, and would prefer to simply use a Rails Engine or sample code if there are any good ones out there. I hate reinventing the wheel. Looking for

Unable to render PDF to browser using Prawn PDF for Ruby on Rails

落爺英雄遲暮 提交于 2019-12-03 06:05:03
问题 I am creating a pdf file in the latest version of the Prawn library (v1.0.1rc) in Rails (3.1.1) and when I run my code it generates the PDF into the root of the application. I don't want this. I want it to render the output into user's browser window, without saving it locally to the server. Please tell me how I can achieve this. Here are my files: views/foo/show.pdf.erb : <%= require 'prawn' pdf = Prawn::Document.new(:page_size => 'LETTER', :page_layout => :landscape, :margin => 50, :top

Why was auto_link deprecated in Rails?

两盒软妹~` 提交于 2019-12-03 06:03:46
I realize it's been pulled into a separate gem, but what's the reason? Is this just a matter of streamlining Rails, or is there some reason I should be weary of auto_link? (The gem says it's meant to 'bridge the gap for people migrating', which suggests to me that if I'm introducing rails_autolink into a new project, I must be doing something wrong, no?) thanks, From the commit where auto_link was removed, Aaron Patterson (tenderlove) explains in the comments: Unfortunately this method is extremely difficult to secure correctly. Ensuring this method is bullet-proof takes a faster release cycle

'sass' in a non thread-safe way

倖福魔咒の 提交于 2019-12-03 05:48:54
问题 I'm getting these warnings when trying to use sass in Rails 3.1 rc1. WARN: tilt autoloading 'sass' in a non thread-safe way; explicit require 'sass' suggested. WARN: tilt autoloading 'sass/plugin' in a non thread-safe way; explicit require 'sass/plugin' suggested. This is my Gemfile. gem "rails", "~> 3.1.0.rc1" gem "haml" gem "sass" I've tried to create a file called sass.rb inside the config/initializers containing this code. require "sass" Changing the Gemfile to this. gem "rails", "~> 3.1