ruby-on-rails-3.1

Rails render route path

旧时模样 提交于 2019-12-02 07:02:15
Im still new to Rails and have a hard time understanding how the path system works in Rails. In my routes.rb i create an alias for signup: match 'signup' => 'user#new' resource :user, :controller => 'user' The action is there and going to /signup shows the correct action. So far so good. Now, when i submit my signup form it runs the create action with POST as usual. And here is where im stuck. If the signup fails, i would like to present the user with the signup form again. One option would be to do a render "new", but that takes the user to /user instead of /signup. UserController class

Rails 3.1.0, geokit, with error acts_as_mappable

青春壹個敷衍的年華 提交于 2019-12-02 07:01:13
I am getting the undefined local variable or method `acts_as_mappable' error when using geokit, and after tons of Goggling and attempts, I cannot seem to be able correct the problem. Basically, I have the following gems installed: geokit (1.6.0, 1.5.0) geokit-rails31 (0.1.3) and have the following in my model class House < ActiveRecord::Base acts_as_mappable end and Gemfile: gem 'geokit', '>= 1.5.0' gem 'geokit-rails31' I get the error with or without doing the following in my local app. rails plugin install git://github.com/jlecour/geokit-rails3.git Okay - Here is the solution for anyone that

Routing errors when upgrading from rails 3.1 to rails 3.2 due to underscores in module namespaces

可紊 提交于 2019-12-02 06:45:23
We have a rails application and we have a API namespace defined as Api::V1, Api::V1_2, Api::V1_3 etc. In routes.rb, we have set the following namespace :api do ["v1", "v1.2", "v1.3", "latest"].each do |name| namespace name, {:module => name.gsub(".","__"), :as => name.gsub(".","_") } do constraints :format => /json/ do # user scoped views resources :some_endpoint, :only => [:create, :index, :show, :update, :delete], :path => "scheduler" do member do put 'edit' post 'duplicate' end end end end end It works fine when running with Rails 3.1, but we get a routing error in rails 3.2 of the form:

Routing error with devise {:controller=>“devise/static”, :action=>“about”}

旧时模样 提交于 2019-12-02 04:53:51
问题 I got a problem with devise. Every time I try to call an Url that should be handled by devise (e.g. http://localhost:3000/users/sign_up) I end up with the following error: No route matches {:controller=>"devise/static", :action=>"about"} Hopefully somebody can help me! routes.rb devise_for :users get "pages/contact" get "pages/imprint" get "pages/about" root :to => "pages#about" What I did: Added gem 'devise' to the gemfile bundle install rails generate devise:install rails generate devise

Creating nested models - Rails 3.1

試著忘記壹切 提交于 2019-12-02 03:54:26
I am trying to create 3 nested models at once, and have trouble with my validations. These are my models: class UserEntity < ActiveRecord::Base has_many :users, :dependent => :restrict, :autosave => true end class User < ActiveRecord::Base has_many :user_login_services, :dependent => :destroy, :autosave => true belongs_to :user_entity end class UserLoginService < ActiveRecord::Base belongs_to :user #validates :user_id, :presence => true end (UserEntity can be a company, with many users. UserLoginService is used for Omniauth services such as Facebook, openID, etc.) Users are created with def

Routing error with devise {:controller=>“devise/static”, :action=>“about”}

北城以北 提交于 2019-12-02 01:57:28
I got a problem with devise. Every time I try to call an Url that should be handled by devise (e.g. http://localhost:3000/users/sign_up ) I end up with the following error: No route matches {:controller=>"devise/static", :action=>"about"} Hopefully somebody can help me! routes.rb devise_for :users get "pages/contact" get "pages/imprint" get "pages/about" root :to => "pages#about" What I did: Added gem 'devise' to the gemfile bundle install rails generate devise:install rails generate devise User rake db:migrate rake routes new_user_session GET /users/sign_in(.:format) {:action=>"new",

undefined method `[]' for #<ActionDispatch::Http::UploadedFile:0x007fae8c0bfaa8>

梦想与她 提交于 2019-12-01 20:38:39
问题 I have nested form with the file_field column, when i try to create it throws NoMethodError in UserController#update undefined method `[]' for # { "utf8"=>"✓", "authenticity_token"=>"HFWawKp4RH7+AFV0yQ1cXpzxHDfubKTKkiDiS6QKnJk=", "user"=> { "name"=>"Test", "image_attributes"=> { "picture"=>#<ActionDispatch::Http::UploadedFile:0x3f4e318 @original_filename="Beautiful Sky_thumb.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"user[pics_attributes][pic]\";

Rails 3.1 Possible Bug in Asset Pipeline and Uglifier

跟風遠走 提交于 2019-12-01 19:48:59
I ran into a problem deploying on Heroku do to a failure in the rake task rake assets:precompile At the bottom is the error I get if I integrate Rails 3.1 Jquery calendar: https://github.com/themouette/jquery-week-calendar Twitter bootstrap The error happens from uglifier. I suspect that problem could be related to the inclusion of many localizations for the calendar. I worked around the error by setting: # Compress JavaScripts and CSS config.assets.compress = false I was not able to examine the files as the temporary files are cleaned up. I also could not get the debugger in RubyMine to stop

undefined method `[]' for #<ActionDispatch::Http::UploadedFile:0x007fae8c0bfaa8>

假如想象 提交于 2019-12-01 19:16:11
I have nested form with the file_field column, when i try to create it throws NoMethodError in UserController#update undefined method `[]' for # { "utf8"=>"✓", "authenticity_token"=>"HFWawKp4RH7+AFV0yQ1cXpzxHDfubKTKkiDiS6QKnJk=", "user"=> { "name"=>"Test", "image_attributes"=> { "picture"=>#<ActionDispatch::Http::UploadedFile:0x3f4e318 @original_filename="Beautiful Sky_thumb.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"user[pics_attributes][pic]\"; filename=\"Beautiful Sky_thumb.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<File:C:/Users/Alex/AppData

rake aborted! uninitialized constant Object::Country, why can't see model?

点点圈 提交于 2019-12-01 18:52:07
I have rails 3.1, I am trying to populate data with seeds.rb I have a model Country which is migrated into a countries table But it seems that rails can't see Country model from seeds.rb I get this error: rake aborted! uninitialized constant Object::Country Tasks: TOP => db:seed my seeds.rb file looks like this: # encoding: UTF-8 Country.delete_all my Country model: class Country < ActiveRecord::Base has_many :students has_many :instructors end any idea please ? EDIT I am in development environment, with config.threadsafe! 来源: https://stackoverflow.com/questions/8628830/rake-aborted