When I use the following line in db/seed.rb:
#Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(self)
User.create!({:name => "debug", :email => "debug#deb.com", :password => "12345678", :password_confirmation => "12345678"})
I get:
/authlogic-3.1.3/lib/authlogic/controller_adapters/abstract_adapter.rb:30:in `params': undefined method `params' for main:Object (NoMethodError)
from /authlogic-3.1.3/lib/authlogic/session/params.rb:96:in `params_credentials'
from /authlogic-3.1.3/lib/authlogic/session/params.rb:72:in `params_enabled?'
from /authlogic-3.1.3/lib/authlogic/session/params.rb:66:in `persist_by_params'
[...]
I have the same error with this command in the console.
Yet everything is fine in the application itself, i only have this issue in db/seed.rb or console.
The first commented line makes no difference (source http://www.tatvartha.com/2009/09/working-with-authlogic-in-scriptconsole/).
Ruby 1.9.3
Rails 3.2.8
Authlogic 3.1.3
Auto-answer:
I had to remove the following from config/environment.rb:
Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(self)
Related
I'm upgrading rails_2 project to rails_3. Have a problem with loading data into view from :(
old environtment: rails 2.3.2, ruby 1.8.7
now : rails 3.2.11, ruby 1.9.3
I have a form_for #lead and observe_form in view
{ :action => :update_price }, :frequency => 0.1 %>
but when I run rails server, I see empty page in browser :(
<%= form_for %> Have you added "=" in the form tag??? – Sachin R
I have models specs, controllers spec and request spec. When I run:
rspec spec
models spec are run first, then request and then when controller specs are run the specs for the first controller are OK, but the next fail. But when I run only the controller specs they all pass. I am with rails 3.0.9, ruby 1.8, factory_girl 2.2.0. I have
config.cache_classes = true
in test.rb and I can't change the version of ruby or factory_girl. Can someone help me?
UPDATE:
This is the error:
96) UsersController reset_password: as non-master_admin: does not reset a user's password
Failure/Error: let!(:user) { Factory(:admin_user) }
ActiveRecord::AssociationTypeMismatch:
AdminUser(#-630697398) expected, got MerchantUser(#-629918188)
# ./app/models/activity.rb:33:in `log'
# ./config/initializers/add_activity_logging.rb:8:in `_callback_after_759'
# ./spec/controllers/users_controller_spec.rb:8
in spec/controllers/users_controller_spec.rb:8:
let!(:user) { Factory(:admin_user) }
in activity.rb:33:
create(:user => user, :title => title, :changeable_id => changeable.id,
:changeable_type => changeable.class.to_s, :data => attributes)
also there is:
belongs_to :user, :class_name => 'AdminUser'
in the class AdminUser there isn't has_many activities but when I tried to add it I couldn't add it correctly I guess.
Thanks for the help
UPDATE:
AdminUser and MerchantUser are descendants of User
POSIBLE FIX
The line that gave error was actually:
admin_user = Factory(:tech_admin)
I replaced it with:
admin_user = FactoryGirl.build_stubbed(:tech_admin)
This way the file activity.rb is not reached
FINAL FIX
Apparently the problem was with Factory(:reseller). I replaced it with FactoryGirl.create(:reseller) and it everything work. Though now I am wondering and searching what is the difference between the two uses
I did same as show in authlogin example. User is created successfully and session also maintained and logout also working fine. After logout I try to login again the application getting following error
NoMethodError in UserSessionsController#create
undefined method `[]' for false:FalseClass
In user_session controller
app/controllers/user_sessions_controller.rb:13:in `create'
UserSessionController Code
...
def create
#user_session = UserSession.new(params[:user_session])
if #user_session.save
flash[:notice] = "Login successful!"
redirect_back_or_default user_path(current_user)
else
render :action => :new
end
end
...
I am using
ruby -v ruby 1.9.2p180
rails -v Rails 3.1.3
authlogic (2.1.6)
After Updating authlogic version 2.1.6 to 3.1.0 it works fine.
I followed the installation procedure of geokit-rails3, here is my conf :
Using rails (3.0.4)
Using activerecord (3.0.4)
Using geokit (1.5.0)
Using geokit-rails (1.1.4)
I get this error "undefined method `within' for #" when i try to query with the "within" method. (note that i am new to rails and maybe missing something obvious)
Here is my class definition :
class Snip < ActiveRecord::Base
belongs_to :user
acts_as_mappable :default_units => :kms,
:default_formula => :sphere,
:distance_field_name => :distance,
:lat_column_name => :latitude,
:lng_column_name => :longitude
end
In my controller i have :
#userLocation = GeoKit::LatLng.new(params[:lat],params[:lng])
#snips = Snip.within(params[:distance], :origin => #userLocation)
Here is what i added to my gemfile :
gem 'geokit', '>= 1.5.0'
gem 'geokit-rails', '1.1.4'
Do you have any idea why i get this error ?
Thanks in advance,
Vincent.
Your gemfile asks for geokit-rails, that's the Rails 2 version. You need to replace that with geokit-rails3
In a plugin helper, I have:
include Rails.application.routes.url_helpers
url_for(:only_path => true, :controller => 'people', :action => 'new')
Note that uses the new include syntax, that part works ok. But I get an error:
undefined local variable or method `controller' for #<ActionView::Helpers::InstanceTag:0x311ddf4>
Is there a new way to specify this, like maybe 'controller#action' ? what's the key?
url_for should work as usual, see http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-url_for
I checked it on my console:
ruby-1.9.2-head > include Rails.application.routes.url_helpers
=> Object
ruby-1.9.2-head > url_for(:only_path => true, :controller => 'admin/providers', :action
=> 'new')
=> "/admin/providers/new"
Maybe the error doesn't occur in the url_for because your error messages says ActionView::Helpers::InstanceTag this sounds like you're using some kind of Tag like link_to etc. Did you think about this?
Best regards
Simon