Rails

Ruby on Rails Mongoid and Webfaction: Not Authorized For Query (Error 16550)

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using version 2.4.4, followed the procedures at http://docs.webfaction.com/software/mongodb.html and am using Mongoid with Ruby on Rails. I also have created a user at the db I am using with the "userAdminAnyDatabase" permission and am using it with this rails mongoid config: production: sessions: default: database: <table> hosts: - localhost:<port> username: <user> password: <password> I have the server runing with --auth flags and I also tried the user with the mongodb cpmmand line and it works but with my Rails app deployed I am

TypeError: Object doesn&#039;t support this property or method

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have created rails application where I created a database (empty). When I try to view my products page, I receive the following error on my http://localhost:3000/products page. Before migrating the database, the application did function. I am using therubyracer and am on Windows 7. ExecJS::ProgramError in Products#index Showing C:/RailsInstaller/DevKit/home/JP/nameofapp/app/views/layouts/application.html.erb where line #16 raised: TypeError: Object doesn't support this property or method (in C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0

Rails + PostgreSQL -Using Like

匿名 (未验证) 提交于 2019-12-03 01:22:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have the following two queries: SELECT users.* FROM "users" WHERE (fname || lname LIKE '%james%') SELECT users.* FROM "users" WHERE (fname || lname LIKE '%James%') I have a record in the User Table with fname = James The problem I'm having is the first query returns 0 results, and the 2nd returns the correct result. I want the LIKE to be case insensitive. Ideas? Thanks 回答1: SELECT users.* FROM "users" WHERE (fname || lname ILIKE '%james%') ILIKE = case-insenstive LIKE. Note that this is specific to PostgreSQL, and not a SQL standard. 回答2:

Styling the date fields of a Rails date_select

匿名 (未验证) 提交于 2019-12-03 01:22:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: In Rails' forms, date select drop-downs are easy: <%= f . label : my_date %> <%= f . date_select : my_date %> Then I get 3 select drop-downs for the year, month and day. Is there an easy way to add HTML between these select elements without using JavaScript? I want to be able to style and label them nicer. 回答1: Convert it to a text field and add a JQuery datepicker or similar. Theres a good guide here, http://railscasts.com/episodes/213-calendars 回答2: You can easily style them with CSS as each part of date_select is postfixed with

sqlite3_native.so: [BUG] Segmentation fault

匿名 (未验证) 提交于 2019-12-03 01:22:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm running into this sqlite3 issue and can't figure out why ; I browsed this forum for many hours and could not find a similar issue reported. I'm using ruby 1.9.3, but the error message seems to invoke ruby 1.8.7 ; I even uninstalled ruby 1.8.7 then sqlite3 and then reinstalled it but that did not solve the issue I'm running rails 3.2.8 user1@company.com [~/rails_apps/myapp]# rails -v Rails 3.2.8 and ruby 1.9.3 user1@company.com [~/rails_apps/myapp]# ruby -v ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-linux] uninstalled ruby 1.8.7

rails 3 warden NameError (uncaught throw `warden'):

匿名 (未验证) 提交于 2019-12-03 01:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: this is how it should work: I log in to the admin panel, go to cars/new and fill up the fields, press create and I should have a new car in my list. www.autozeep.com the thing is that it goes ok until I press the Create button to create the new car, server logs shows this: NameError ( uncaught throw `warden'): app/controllers/application_controller.rb:9:in ` login_required ' app/middleware/flash_session_cookie_middleware.rb:17:in `call' in the development mode this is working fine, on the server in production mode it's not, it's

Getting config.eager_load is set to nil while trying to run rails c in test

匿名 (未验证) 提交于 2019-12-03 01:19:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to run the rails ( 4.1.2 ) console rails c RAILS_ENV=test And I'm getting this: > config.eager_load is set to nil. Please update your > config/environments/*.rb files accordingly: > > * development - set it to false * test - set it to false (unless > you use a tool that preloads your test environment) * production - > set it to true > > /Users/xxxxxx/.rvm/gems/ruby-2.2.2/gems/activerecord-4.1.12/lib/active_record/connection_adapters/connection_specification.rb:257:in > `resolve_symbol_connection': 'RAILS_ENV=test' database is not

Rails: how to require at least one field not to be blank

匿名 (未验证) 提交于 2019-12-03 01:18:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I know I can require a field by adding validates_presence_of :field to the model. However, how do I require at least one field to be mandatory, while not requiring any particular field? thanks in advance -- Deb 回答1: You can use: validate :any_present? def any_present? if %w(field1 field2 field3).all?{|attr| self[attr].blank?} errors.add :base, "Error message" end end EDIT: updated from original answer for Rails 3+ as per comment. But you have to provide field names manually. You could get all content columns of a model with Model.content

Rails: AbstractController::Helpers::MissingHelperError - Missing helper file application_helper.rb_helper.rb

匿名 (未验证) 提交于 2019-12-03 01:18:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Can't find any resource that's helped me in this! When I try to 'rails s' and go to any page of the app; it shoots me this error page saying I am missing helper files. I think it's local on my desktop machine because I recently did some work to the app on my laptop. I pushed from the laptop and app works fine on Heroku and runs local on that machine with zero problems. I added a feature to upload company logo images using Carrierwave, Mini_Magick, and Fog to Amazon S3. Things I've tried so far: I've deleted the app and git clone it

windows: rails: error installing bson_ext

匿名 (未验证) 提交于 2019-12-03 01:18:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: when trying to install bson_ext i see the error...installing json gem works fine which also requires building native extensions - i have tried everything see similar questions with no good answer $ gem install bson_ext Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... ERROR: Error installing bson_ext: ERROR: Failed to build gem native extension. c:/Ruby193/bin/ruby.exe extconf.rb checking for asprintf()... no checking for ruby/st.h... yes checking for ruby/regex.h... yes checking for ruby