Unfortunately the problem does not appear to be a routes problem but a
'not initialised' authlogic problem. By changing the App.Controller
methods I have now moved the problem to the create procedure after
logging on. I managed to create a user from the console and Authlogic
filled in all the 'special' fields. But logging on and calling the
create session (call Authentication) causes the same error
undefined method `underscore' for nil:NilClass
which occurs when calling @authentication.save.
def create
@authentication = Authentication.new(params[:authentication])
if @authentication.save
flash[:notice] = "Login successful!"
redirect_to root_url
else
render :action => :new
end
end
My App.Controller now has the session/user checking methods and cause
no problems. (so far)
private
def current_user
return @current_user if defined?(@current_user)
@current_user = current_user_session && current_user_session.user
end
def current_user_session
return @current_user_session if defined?(@current_user_session)
if defined?(Authentication.Find) then
@current_user_session = Authentication.find
else
@current_user_session=nil
end
end
I am using rails 2.3.8 and Authlogic 2.1.6, and I like to try and keep
to one word descriptions of models and controls so Authentication
instead of UserSession.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Unfortunately the problem does not appear to be a routes problem but a
'not initialised' authlogic problem. By changing the App.Controller
methods I have now moved the problem to the create procedure after
logging on. I managed to create a user from the console and Authlogic
filled in all the 'special' fields. But logging on and calling the
create session (call Authentication) causes the same error
undefined method `underscore' for nil:NilClass
which occurs when calling @authentication.save.
def create
@authentication = Authentication.new(params[:authentication])
if @authentication.save
flash[:notice] = "Login successful!"
redirect_to root_url
else
render :action => :new
end
end
My App.Controller now has the session/user checking methods and cause
no problems. (so far)
private
def current_user
return @current_user if defined?(@current_user)
@current_user = current_user_session && current_user_session.user
end
def current_user_session
return @current_user_session if defined?(@current_user_session)
if defined?(Authentication.Find) then
@current_user_session = Authentication.find
else
@current_user_session=nil
end
end
I am using rails 2.3.8 and Authlogic 2.1.6, and I like to try and keep
to one word descriptions of models and controls so Authentication
instead of UserSession.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I need to change the type of a column (wasserstand) from string to
integer, which already contains text.
My idea is to copy the string into a new scratch column, modify the
column type to integer and then manually set the appropriate ints.
After this, I want to remove the scratch string column in the next
migration.
The first migration should be done like this:
def self.up
tz = Teilzaehlung.all
ws = []
tz.each do |b|
ws << [b.id, b.wasserstand]
end
change_column(:teilzaehlungs, :wasserstand, :integer)
add_column(:teilzaehlungs, :wst, :string)
ws.each do |b|
beob = Teilzaehlung.find(b[0])
beob.update_attribute(:wasserstand, 0)
beob.update_attribute(:wst, b[1])
end
end
Interestingly, after running the migration, the new interger typed
column contains 0, but the scratch column wst is always NULL - even if
b[1] contains a string.
Why?
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.