ruby-on-rails-3.1

How can I run SOME initializers when doing a Rails assets:precompile?

ⅰ亾dé卋堺 提交于 2019-12-02 22:46:58
Background I have an app that I recently updated to Rails 3.2.1 (from Rails 3.0.x) and have refactored the JS and CSS assets to make use of the new asset pipeline. The app is hosted on Heroku with the Celadon Cedar stack. App Config I keep application specific configuration in a YAML file called app_config.yml and load it into a global APP_CONFIG variable using an initializer: # config/initializers/load_app_config.rb app_config_contents = YAML.load_file("#{Rails.root.to_s}/config/app_config.yml") app_config_contents["default"] ||= {} APP_CONFIG = app_config_contents["default"].merge( app

Heroku is trying to install sqlite3 gem even it not being in the Gemfile

六眼飞鱼酱① 提交于 2019-12-02 22:43:28
I'm trying to deploy a Rails 3.1 application for the first time on Heroku. I set it to the Cedar stack, removed the sqlite3 gem but when I push the code to Heroku I get this error: -----> Installing dependencies using Bundler version 1.1.rc Running: bundle install --without development:test --path vendor/bundle --deployment Fetching gem metadata from http://rubygems.org/ ....... (...) Installing rails (3.1.0) Installing sqlite3 (1.3.4) with native extensions Unfortunately, a fatal error has occurred. Please report this error to the Bundler issue tracker at https://github.com/carlhuda/bundler

Carry Sass variables through the Assets Pipeline, Rails 3.1 rc1

。_饼干妹妹 提交于 2019-12-02 21:43:02
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 converts the ".css.sass" files to raw css before appending it to the rest of the code. So if i specify, in my

rails 3.2.2 (or 3.2.1) + Postgresql 9.1.3 + Ubuntu 11.10 Connection error

倾然丶 夕夏残阳落幕 提交于 2019-12-02 20:58:44
I am using PostgreSQL 9.1.3 (PostgreSQL 9.1.3 on x86_64-pc-linux-gnu, compiled by gcc-4.6.real (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1, 64-bit) and rails either 3.2.2 or 3.2.1 on ubuntu 11.10. Now, I can connect with below command with PostgreSQL su postgres enter password and I can see postgres=# I am placing below details in my config/database.yml and executing " rails db " it is working fine. development: adapter: postgresql encoding: utf8 reconnect: false database: sample_app_db pool: 5 username: postgres password: passwordhere host: localhost I am using rvm to access my rails environment.

Integrating CKEditor with Rails 3.2

半腔热情 提交于 2019-12-02 19:49:57
Similar to Integrating CKEditor with Rails 3.1 Asset Pipline I am trying to integrate ckeditor with my rails 3.2 application. I have all ckeditor files copied under /app/assets/javascripts/ckeditor/* . I have the following lines in my application.js and application.js is included in my layout file: //= require jquery //= require jquery_ujs //= require ckeditor/ckeditor //= require_self Taken it from the answer to Integrating CKEditor with Rails 3.1 Asset Pipline I can understand that I need to add something like: config.assets.precompile += your_files to my development.rb file so that all the

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

空扰寡人 提交于 2019-12-02 19:33:13
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_margin => 20, :bottom_margin => 50) ..... render_file("foo.pdf") %> controllers/foo_controller : class

'sass' in a non thread-safe way

主宰稳场 提交于 2019-12-02 19:11:06
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.0.rc1" gem "haml" gem "sass", require: false But the warnings remains. Anyone knows how to solve it? I

Rails 3.1 asset pipeline doesn't pick up changes to @import'd sheets

让人想犯罪 __ 提交于 2019-12-02 18:15:01
I use @import 'd partial sheets to organize my css/sass: /app /assets /stylesheets _constants.sass _layout.sass ... app.css.sass app.css.sass: @import _constants.sass // basic styles @import _layout.sass @import ... app.css.sass has an @import rule for _layout.sass , which allows me to share mixins and variables amongst the raw sass files before they're complied down into app.css The problem is that Rails doesn't recognize changes to the @import 'd partials ( _layout.sass ) and won't regenerate app.css until I make a change to the actual app.css.sass file itself. This dramatically slows down

How do you quote strings in Postgres

不想你离开。 提交于 2019-12-02 18:05:13
问题 In Rails I use MySQL and have SnCl.all(:conditions => "col3=\"xx\"") but it does not work with my Postgres DB in Heroku 回答1: As mentioned in the comments, most databases uses single quotes for string literals and double quotes for identifiers. MySQL is rather lax and will also accept double quotes for string literals but PostgreSQL is (thankfully) quite strict. So you want to use single quotes: SnCl.all(:conditions => "col3 = 'xx'") or using where : SnCl.where("col3 = 'xx'") or with sensible

Micropost - Routing Error No route matches [GET] - Deleting a Micropost

冷暖自知 提交于 2019-12-02 17:52:10
问题 I'm reading through Hartl's book, Ruby on Rails by Example. In chapter 11, it has you implement delete requests to allow users to delete microposts on their profile. However when I click the delete button, I receive this routing error: No route matches [GET] /microposts/303" I've found similar posts with other people who have had the same problem. But no one seems to have figured out a clear way to resolve this issue. Maybe it is just too late at night but I am stumped. I know it has