user has_many log_entries, log_entry belongs to user
Reported by Don Ziesig | March 13th, 2010 @ 11:04 PM
class User < ActiveRecord::Base
hobo_user_model # Don't put anything above this
fields do * * end
has_many :log_entries;
end
class LogEntry < ActiveRecord::Base
hobo_user_model # Don't put anything above this
fields do * * user_id :integer; end
belongs_to :user
end
end;
In rails, I can set the value of user_id in the log_entry controller. Since there are no appropriate members in the log_entry controller, I tried (unsuccessfully) to get current_user in the log_entry model. I didn't think this would be visible and I was right.
This is a very simple hobo program. All I want it to do is keep the log entries of separate users separate in the db and at the UI.
When I create log entries, the user_id field is not populated.
Am I missing something simple?
Thanks in advance,
Don Ziesig
Comments and changes to this ticket
-
Betelgeuse March 14th, 2010 @ 08:30 AM
Things to note:
- You should use hobo_model instead of hobo_user_model when your model is not User (I recommend using the hobo generators like hobo_model_resource to create things)
- You are not supposed to put user_id into the fields block. Hobo extends belongs_to and finds it that way
- The hobo documentation for controllers can be found at http://cookbook.hobocentral.net/manual/controllers
- Bug trackers are not support channels. Use the group at http://groups.google.com/group/hobousers
-
Bryan Larsen April 1st, 2010 @ 03:37 PM
- State changed from new to invalid
I like the tag you chose. :)
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »