ruby-on-rails-3.1

Rails 3.1 assets pipeline in production

一世执手 提交于 2019-11-27 18:36:14
问题 I am using the assets pipeline (in Rails 3.1.3) and am kind of struggling to make it work in production. Situation In my /app/assets/stylesheets directory I have the following files: application.css --> this is the default rails one stylesheet.css --> This is my custom stylesheet I spent a lot of time getting my stylesheet.css included in the /public/assets/ directory in production (by running rake assets:precompile ) and I finally made it by adding the following line into in my application

HTML5 VIDEO is not working in my rails 3 app

柔情痞子 提交于 2019-11-27 18:18:13
问题 I am trying to display HTML5 video in my Rails 3 app in development,i am using Sqlite3 and default webserver(Webrick).I put the video file (movie.ogg) under assets (assets/movie.ogg).The video window screen shows up but there is no video on there though.I have 3 questions...Since rails app assets doesn't have sub-folder for video(as the way it has images),where do you put video files? Does Webrick support Html5 video?Here is my code below ,what am i missing here,to make the video work? view

No route matches [GET] “/users/sign_out”

萝らか妹 提交于 2019-11-27 18:11:05
Here is my actual error: No route matches [GET] "/members/sign_out" Since most people will use "users" I thought it would be more helpful to have that in the title. At any rate, I am essential unable to logout. I can successfully edit my member profile. I am using devise 1.4.2 and Rails 3.1.0.rc4. Also, I have generated two separate devise models - one called "members" and the other called "admins". I was able to register and log into both of them (simultaneously) by manually navigating to the correct URL path (i.e., localhost:3000/admins/sign_in/). I created some links within my application

Rails asset pipeline: Standard way for including all /vendor/assets/javascripts/?

杀马特。学长 韩版系。学妹 提交于 2019-11-27 18:06:05
I've been transitioning an app to Rails 3.1 (and now on to 3.2) and watched the Railscast on the asset pipeline . I moved all of my third-party jquery plugin files to the /vendor/assets/javascripts/ directory. In my /app/assets/javascripts/application.js I have the following: //= require jquery //= require jquery_ujs //= require_tree . //= require_self I realized the require_tree . call only loads the tree for the /app/assets/javascripts/ directory. (Is that correct?) What's the best way to include all the "vendor" javascripts? (I'm not worried about ordering at this point.) Of course I could

Best way to highlight current page in Rails 3? — apply a css class to links conditionally

橙三吉。 提交于 2019-11-27 17:49:15
For the following code: <%= link_to "Some Page", some_path %> How do I apply a css class current using the current_page?‎ helper method? Or if some other better way is available? In app/helpers/application_helper.rb def cp(path) "current" if current_page?(path) end In your views: <%= link_to "All Posts", posts_path, class: cp(posts_path) %> Basically write a simple wrapper around it. Additionally you could extend the method to allow additional classes to be applied by adding arguments. Keeps the views concise/dry. Or, without extending the method, you could just do simple String interpolation

overriding devise after_sign_up_path_for not working

﹥>﹥吖頭↗ 提交于 2019-11-27 17:16:42
问题 In routes i have the root-path pointing "home#index" but when i try to override that with after_sign_up_path_for keeps redirecting me to the root path when I sign in or sign up. I have tried to put it in both in devise subclassed controller and application_controller, but it didn't work. What do I need to do here? Application controller class ApplicationController < ActionController::Base protect_from_forgery def after_sign_up_path_for(resource) show_cities_path(resource) end end registration

Speed up assets:precompile with Rails 3.1/3.2 Capistrano deployment

家住魔仙堡 提交于 2019-11-27 16:38:45
My deployments are slow, they take at least 3 minutes. The slow Capistrano task during deploy is assets:precompile. This takes probably 99% of the total deploy time. How can I speed this up? Should I precompile my assets on my local machine and add them to my git repo? Edit: Adding config.assets.initialize_on_precompile = false to my application.rb file dropped the precompile time with half a minute, but it is still slow. tommasop The idea is that if you don't change your assets you don't need to recompile them each time: This is the solution that Ben Curtis propose for a deployment with git:

Rails 3.2, FATAL: Peer authentication failed for user (PG::Error)

穿精又带淫゛_ 提交于 2019-11-27 16:35:36
I am running my development on Ubuntu 11.10, and RubyMine Here is my development settings for the database.yml: which RubyMine created for me development: adapter: postgresql encoding: unicode database: mydb_development pool: 5 username: myuser password: when I try to run the app, I get this error below, it seems that I didn't create a 'project' user yet, but, how can I create a user and grant it a database in postgres ? if this is the problem, then, what is the recommended tool to use in Ubuntu for this task ? if this is not the problem, then, please advice. Exiting /home/sam/.rvm/gems/ruby-1

Curl on Ruby on Rails

落花浮王杯 提交于 2019-11-27 16:30:14
问题 how to use curl on ruby on rails? Like this one curl -d 'params1[name]=name&params2[email]' 'http://mydomain.com/file.json' 回答1: Just in case you don't know, it requires 'net/http' require 'net/http' uri = URI.parse("http://example.org") # Shortcut #response = Net::HTTP.post_form(uri, {"user[name]" => "testusername", "user[email]" => "testemail@yahoo.com"}) # Full control http = Net::HTTP.new(uri.host, uri.port) request = Net::HTTP::Post.new(uri.request_uri) request.set_form_data({"user[name]

rake assets:precompile taking extremely long to complete

只谈情不闲聊 提交于 2019-11-27 16:02:35
问题 In my dev sandbox RAILS_ENV=production rake assets:precompile is taking over 4 minutes to complete. Is this normal. On heroku it is taking over 10 minutes to do the job and sometimes is timing out. Is there any way to disect this and/or speed it up? UPDATE I profiled the CSS vs JS phases of compilation 3.7 s js 175 s css The numbers were made by instrumenting here ---------------------- /Users/bradphelan/.rvm/gems/ruby-1.9.2-p180@gobbq/gems/sprockets-2.1.2/lib/sprockets/processing.rb --------