ruby-on-rails-3.1

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

旧街凉风 提交于 2020-01-11 16:36:25
问题 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

Rails, Authlogic without password (registration ok. user_session validation fails)

青春壹個敷衍的年華 提交于 2020-01-11 12:09:32
问题 I am trying to skip the password for Users in Authlogic.. Thanks to SO, I found a solution for creating users User acts_as_authentic do |c| c.validate_password_field = false c.validate_email_field = false end The User_session is still giving a problem - any time I try to log in I get "password cannot be blank".. how to bypass validation on user session? 回答1: Actually found it here: Using Authlogic to authenticate with only a username Just pass a user object instead of login/password

CSS in Rails Asset Path not processed by ERB in development

╄→尐↘猪︶ㄣ 提交于 2020-01-10 20:06:05
问题 I have a Rails app with the following in /app/assets/stylesheets/styles.css.erb : ... #nestedbg { background-position: left top; background-image: url(<%= asset_path 'siteheader2.png' %>); background-repeat: repeat-x; background-attachment: fixed; } ... When I run rake assets:precompile and then run rails s -e production , everything works as expected. However, when I remove the precompiled assets and run rails s in development, the CSS file comes up as shown above instead of being properly

Why I can not call super in define_method with overloading method?

China☆狼群 提交于 2020-01-10 14:12:40
问题 When I run code below it raise error: implicit argument passing of super from method defined by define_method() is not supported. Specify all arguments explicitly. (RuntimeError). I am not sure what is the problem. class Result def total(*scores) percentage_calculation(*scores) end private def percentage_calculation(*scores) puts "Calculation for #{scores.inspect}" scores.inject {|sum, n| sum + n } * (100.0/80.0) end end def mem_result(obj, method) anon = class << obj; self; end anon.class

Why I can not call super in define_method with overloading method?

穿精又带淫゛_ 提交于 2020-01-10 14:11:55
问题 When I run code below it raise error: implicit argument passing of super from method defined by define_method() is not supported. Specify all arguments explicitly. (RuntimeError). I am not sure what is the problem. class Result def total(*scores) percentage_calculation(*scores) end private def percentage_calculation(*scores) puts "Calculation for #{scores.inspect}" scores.inject {|sum, n| sum + n } * (100.0/80.0) end end def mem_result(obj, method) anon = class << obj; self; end anon.class

rails 3.1 ActionController::RoutingError (No route matches [GET] “/assets/rails.png”):

▼魔方 西西 提交于 2020-01-10 12:04:34
问题 Standard new rails app has issue showing the rails.png ActionController::RoutingError (No route matches [GET] "/assets/rails.png"): I have tried moving the .png file around to various places in assets and assets/images and also the older place 'public' or 'public/images' and changing the page but nothing has helped. Please answer if you have seen and resolved this. I have tried about 20 different combo's myself. Version: 'rails', '3.1.0.rc4' 回答1: I just had a problem throwing a similar error.

rails 3.1 ActionController::RoutingError (No route matches [GET] “/assets/rails.png”):

蹲街弑〆低调 提交于 2020-01-10 12:03:07
问题 Standard new rails app has issue showing the rails.png ActionController::RoutingError (No route matches [GET] "/assets/rails.png"): I have tried moving the .png file around to various places in assets and assets/images and also the older place 'public' or 'public/images' and changing the page but nothing has helped. Please answer if you have seen and resolved this. I have tried about 20 different combo's myself. Version: 'rails', '3.1.0.rc4' 回答1: I just had a problem throwing a similar error.

Rails: Use livereload with Asset Pipeline

别来无恙 提交于 2020-01-09 19:29:42
问题 Quick question for rails pros out there... When working with Rails 3.0.x apps I was a heavy user of Guard and LiveReload. However, it seems that when using the asset pipeline in Rails 3.1 the livereload guard does not know that changes to a Sass file should trigger sending new css to the browser. Is anyone using LiveReload with the Asset Pipeline? If so, how are you making it work? Thanks! 回答1: After following some issue threads on Github I found the following fixed my problem: 1) Make sure

rails3-jquery-autocomplete and writing own search query

荒凉一梦 提交于 2020-01-07 06:41:26
问题 This is my controller, where I use autocomplete gem. I am getting the error for this query: SELECT users.id, users.phone, first_name, last_name FROM "users" WHERE (LOWER(users.phone) ILIKE '77%') ORDER BY users.phone ASC LIMIT 10): ActiveRecord::StatementInvalid (PGError: ERROR: function lower(integer) does not exist My controller: class CarsController < ApplicationController autocomplete :user, :phone ... end I would like to ask you, how can I do my own db query for autocomplete searching -

How to use created_at value as default in Rails

淺唱寂寞╮ 提交于 2020-01-07 04:28:27
问题 How can I set one of my database table to created_at as default value. I did this but didn't work, I have checked in the DB and the value of code is null. class CreateEvents < ActiveRecord::Migration def change create_table :events do |t| t.string :title t.string :location t.text :description t.date :occurs_on t.string :code, :default => Event::created_at t.timestamps end end end 来源: https://stackoverflow.com/questions/9087494/how-to-use-created-at-value-as-default-in-rails