ruby-on-rails-3.1

How do I get escape_javascript and other helpers in my sprockets pre-processed js file (not a view)?

血红的双手。 提交于 2019-12-04 17:30:31
问题 I'm using Rails 3.1 and the sprockets stuff. I want to use ERB to pre-process a js file that will then be included using javascript_include_tag. It is generated from code, and so I'm pre-processing it with ERB, but I can't get to the helpers like escape_javascript from ActionView::Helpers::JavaScriptHelper Say my file is called dynamic.js.erb, and it contains obj = { name: "test", tag: "<%= escape_javascript( image_tag( "logo.png" ) )%>" }; How do I stop it from producing the error: throw

Rails 3.1 asset urls in SCSS files do not seem to be referencing the assets correctly

余生长醉 提交于 2019-12-04 17:23:15
I just upgraded from Rails 3.0 to Rails 3.1. I have a foo.css.scss file that references an image ( /app/assets/images/foo.png ) as follows: .foo { background-image: image-url('foo.png'); } The problem is that my foo.png file is not loaded and I see 404 errors in my logs. The actual css entry that is generated is: background-image: url(/images/foo.png); which is wrong (?) because the image can be found at /assets/foo.png and not at /images/foo.png . Note that I am still working on development mode. Another important note. If I rename my foo.css.scss file to foo.css.erb and use: background-image

openssl smime in ruby/rails

送分小仙女□ 提交于 2019-12-04 17:18:58
So, i have this application that creates a zip file with images and stuff and i want to sign it using smime . if i use the terminal command: openssl smime -binary -sign -passin "pass:MYPASS" -signer ./MyCertificate.pem -inkey ./MyKey.pem -in ./manifest.in -out ./signature.out -outform DER Formated: openssl smime -binary -sign -passin "pass:MYPASS" \ -signer ./MyCertificate.pem -inkey ./MyKey.pem \ -in ./manifest.in -out ./signature.out -outform DER the manifest.in is the file witch contains the text to be signed and signature.out is the output file. i don't know a lot about signing but i

What is the new format for rake tasks? (task :t, arg, :needs => [deps] versus task :t, [args] => [deps])

孤街醉人 提交于 2019-12-04 16:53:08
问题 I'm using Rails 3.1 beta with Ruby 1.9.2 and rake 0.9.2, and have a bunch of rake tasks I've written. Here is an example: namespace :data do desc "dump the nodes and edges for a graph" task :dump_graph, :species_id, :needs => :environment do |t,args| args.with_defaults(:species_id => 'Hs') # ... end end When my rails app loads these rake tasks, however, I now get the following warning repeated once for each rake task: at /home/user/railsapp/lib/tasks/data/dump_graph.rake:3:in `block in <top

How do I redirect back to a page I'm currently on?

☆樱花仙子☆ 提交于 2019-12-04 16:31:00
问题 In my users photo album page they see photos they have uploaded and each photo has a 'make default' link on it. When the user clicks make default , then the id of the photo is stored in the photo_id column of my profiles table. The issue is redirecting them back to: localhost:3000/settings/photo_gallery/:id Is there a way I can redirect back to the photo album using the id of the photo that has just been set as the default? Can Rails find what album I want to redirect to just by looking at

Dependency included in gemspec not added to asset pipeline in rails engine

白昼怎懂夜的黑 提交于 2019-12-04 15:48:25
问题 I'm writing a rails engine that has some dependencies. I've specified the dependencies in the gemspec and the engine is finding them when I run bundle install (i.e. Gemfile.lock looks correct). When I want to use the plugin in a Ruby file, I can do so but need to explicitly require dependency-name at the top of the file. However, when I want to use the dependency's asset pipeline, sprockets can't find it. The app I'm using (for now) is the dummy app that comes in a rails plugin's test folder.

ruby on rails 3.1 move .swf to asset pipeline?

断了今生、忘了曾经 提交于 2019-12-04 15:35:19
问题 Is it possible to move SWF files to the asset pipeline, and if possible how can this be done? 回答1: I would recommend putting them in a folder called app/assets/flash . Add this folder to your asset paths: config.assets.paths << Rails.root.join('app', 'assets', 'flash') They can be referenced like this in your views: asset_path('name_of_swf') The asset_path helper will ensure the correct file is referenced in development and production modes. 来源: https://stackoverflow.com/questions/8990393

Static pages and assets in Rails 3.1.1

一曲冷凌霜 提交于 2019-12-04 15:11:10
问题 Currently working on a project where we need to drop in various static html pages + static assets for those from time to time that "just work." We cannot have anyone editing the html directly to place paths in for the assets. We need it to simply work such that the html + asset folders are placed directly into /public and the content is served up as it was generated. When testing this behavior in production, it's a no go with errors such as: ActionController::RoutingError (No route matches

Passenger & Nginx => 502 Bad Gateway Errors in Production

霸气de小男生 提交于 2019-12-04 15:09:15
问题 I am running Nginx 1.0.6, Passenger 3.0.9, Rails 3.1.1, Ruby 1.9. In my production environment I am seeing the following intermittent warnings in my nginx_error.log file: 2011/11/22 14:44:40 [warn] 23288#0: *474 an upstream response is buffered to a temporary file /opt/nginx/proxy_temp/2/00/0000000002 while reading upstream, client: 69.172.88.178, server: www.memverse.com, request: "GET /show_all_my_verses HTTP/1.1", upstream: "passenger:unix:/passenger_helper_server:", host: "www.memverse

ERROR NoMethodError: undefined method `debug_rjs=' for ActionView::Base:Class

孤者浪人 提交于 2019-12-04 15:02:07
问题 This project was built with rails 3.0.9. Now i updated the gems and Gemfile => source 'http://rubygems.org' gem 'rails', '3.1.1' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'pg' gem 'devise' gem "will_paginate" gem 'ruby-debug19' gem 'rack', '1.3.3' gem 'jquery-rails' After rails s, when i do , http://0.0.0.0:3000/ i get this error => => Booting WEBrick => Rails 3.1.1 application starting in development on http://0.0.0.0:3000 => Call with -d to