ruby-on-rails-3

lib directory is not looked in by default

早过忘川 提交于 2020-01-05 07:52:49
问题 I following Ryan's subdomain railscast where het creates a Subdomain class used in his routes and places it in the lib directory. Apparantly my rails app isn't looking in the lib dir by default (my app only starts when I move the subdomain.rb file from lib to eg /app/models) I always thought that the lib dir was included by default in a rails app? How can I best include this directory to make this happen. Thanks 回答1: Rails 3 does not autoload it by default (although Rails 2 does). You have to

lib directory is not looked in by default

自闭症网瘾萝莉.ら 提交于 2020-01-05 07:52:32
问题 I following Ryan's subdomain railscast where het creates a Subdomain class used in his routes and places it in the lib directory. Apparantly my rails app isn't looking in the lib dir by default (my app only starts when I move the subdomain.rb file from lib to eg /app/models) I always thought that the lib dir was included by default in a rails app? How can I best include this directory to make this happen. Thanks 回答1: Rails 3 does not autoload it by default (although Rails 2 does). You have to

jQuery fileupload plugin success call back

旧时模样 提交于 2020-01-05 07:30:36
问题 I used the jQuery File Upload Plugin (https://github.com/blueimp/jQuery-File-Upload) to upload multiple pictures simultaneously in rails. The photo is attached to the Item model, and item is added to a poll. Using the plugin as: $(document).ready(function(){ $('#fileupload').fileupload({ url: '/polls', dataType: "json", done: function(e,data){ window.location = "/polls/" + data.result.id; } } }); It was expected to call the create action in the Poll Controller for each photo file and redirect

Heroku [WARNING] You provided devise_for :users but there is no model User defined in your application

僤鯓⒐⒋嵵緔 提交于 2020-01-05 07:26:09
问题 I have an rails 3 (3.0.9) application working on ruby 1.8.7 with the gem devise (1.4.2) on my computer working perfectly. I tried to push it on heroku and i got the following error message on application load: [WARNING] You provided devise_for :users but there is no model User defined in your application => Booting WEBrick => Rails 3.0.9 application starting in production on http://0.0.0.0:43292 => Call with -d to detach => Ctrl-C to shutdown server Exiting /app/vendor/bundle/ruby/1.9.1/gems

Rails internationalisation help

纵饮孤独 提交于 2020-01-05 07:06:24
问题 I have downloaded the danish locale (da.yml) and put it in config/locales I get this error: couldn't parse YAML at line 20 column 14 It is the same error as I get in in simple form for Rails 3 simple form error : couldn't parse YAML My application.rb: require File.expand_path('../boot', __FILE__) require 'rails/all' # If you have a Gemfile, require the gems listed there, including any gems # you've limited to :test, :development, or :production. Bundler.require(:default, Rails.env) if defined

Rails 3.2.11 asset precompile fails if threadsafe! enabled

橙三吉。 提交于 2020-01-05 07:00:33
问题 I'm on Rails 3.2.11 and ruby 1.9.3.125 My app is working ok in devel and production if threadsafe! off With threadsafe! enabled I get an error during precompiling, in my asset assetsolutions.js.erb (which is the main js file of the application) I use the Workorder class as in the next line if ($('#workorder_worktype').val()=='<%= Workorder::REPAIR %>') with threadsafe! the class can't be found at precompile time, I've done some reasearch and I think it may be related with rails switching off

Rails 3.2.11 asset precompile fails if threadsafe! enabled

旧时模样 提交于 2020-01-05 07:00:13
问题 I'm on Rails 3.2.11 and ruby 1.9.3.125 My app is working ok in devel and production if threadsafe! off With threadsafe! enabled I get an error during precompiling, in my asset assetsolutions.js.erb (which is the main js file of the application) I use the Workorder class as in the next line if ($('#workorder_worktype').val()=='<%= Workorder::REPAIR %>') with threadsafe! the class can't be found at precompile time, I've done some reasearch and I think it may be related with rails switching off

Log incident when an account is locked after three failed attempts with Devise

社会主义新天地 提交于 2020-01-05 06:51:12
问题 I want to log in the database the incident when a users account is locked, I'm using Rails3 and Devise, so I think I'll need to override some action in a Devise controller, I just don't know wich controller/action and how to capture the users Id. Any tips? 回答1: I know this is an old question, but the easiest approach is probably to override lock_access! from the lockable mixin (in your user model): def lock_access! super # record an account lock here end 来源: https://stackoverflow.com

Cannot upload file

烈酒焚心 提交于 2020-01-05 05:44:05
问题 I have problems to upload a file: Here is my html: <%= form_tag import_test_path, multipart: true do %> <%= file_field_tag :file, :style => 'display:inline; margin-top:-10px' %> <%= submit_tag 'Hochladen', :class => 'btn btn-sm btn-info' %> <% end %> First i tried to simply upload it and to handle it in my controller like this: def import widgets = DBF::Table.new(params[:file], nil, 'cp1252') w = widgets.find(6) p = Patient.new p.vorname = w.vorname p.name = w.name p.geburtsdatum = w.geburt p

How do I sort a parent class based on an attribute of the child class?

隐身守侯 提交于 2020-01-05 04:51:26
问题 I have what seemed to me a simple requirement: I want to sort a parent class based on an attribute of its child class. class owner has_many :tasks end class task belongs_to :owner end Now I want to sort the owners based on the due date on their tasks, so that the owner that has the task with the "closest" due date is first, etc I can do this in Ruby with array sorting, but my record sets are huge and i need to do this with AR / DBMS.. UPDATE: As I am pondering this question part of the