similar to: Showing current user''s information and saving

Displaying 20 results from an estimated 9000 matches similar to: "Showing current user''s information and saving"

2006 Apr 02
1
One to Many Relationship Issues
Hi, I am having issues with a one to many relationship(it never works :-)). Jokes aside, I am getting an error: Mysql::Error: #23000Cannot add or update a child row: a foreign key constraint fails: INSERT INTO adverts (`image_url`, `price`, `title`, `website_url`, `description`, `user_id`) VALUES(''bb'', 22.0, ''aa'',
2007 Aug 29
2
assign local variable instead of instance variable.
Hello, I have a view that generates a list of adverts with <%= render :partial => ''advert'', :collection => @adverts %> I have the render call described with @controller.template.should_receive(:render).with(:partial => ''advert'', :collection => @adverts) Bu when i was about to describe my partial i got stuck. My partial _advert.rhtml:
2006 Jul 21
1
Passing a variable between methods
Hi, I am trying to add search functionality to may application. I am struggeling to pass my query to the controller and then show all my search results in another view. How would I do this? Model: class Advert < ActiveRecord::Base belongs_to :user def self.search(query) if !query.to_s.strip.empty? tokens = query.split.collect {|c| "%#{c.downcase}%"}
2006 Apr 21
9
Yet another dry question..
One of these days I''ll figure this out, but in the meantime help me be a better programmer by eliminating some excess code: I''m trying to check to see if somebody trying to view/edit/update a product is the owner. In my scaffold I have this code that works: def edit @owner = Product.find(params[:id].to_i) if @owner.user_id == @user.id @product =
2006 Jan 15
8
Underscore character in session var
I stumbled across a weird problem i can do: @session[:userid] = 1 but cant: @session[:user_id] = 1 The second session var doesnt set. Is there a config setting for this? -- Posted via http://www.ruby-forum.com/.
2006 Jun 02
6
Set instance variable for all actions in the Controller
Can I set an application wide instance variable that is available for all actions...and their views? eg. class ApplicationController < ActionController::Base @current_user = User.find(session[:user_id]) end and everywhere I can call @current_user.id and I can get that object? Even down in the views? I could not get this to work... Thanks in advance, Jeff -------------- next part
2006 Jan 24
9
Constructors
Hi all, A little question. How can u use an constructor in controller? I would like to initialize some central stuff before i''m processing the controller. thanks in advance, Martijn
2006 Feb 16
6
session usage
Clearly I have the session and can see that session[:user_id] = 7 Now I want to use the results of this...in a page...so I am trying to use the instance variable @sess_user and at the top of the application controller, I have either... @sess_user = User.find([:first, "id = ?", session[:user_id]) or @sess_user = User.find([:first, "id = ?", session[:user_id]) gives me an
2006 Apr 10
6
Single Table Mapping
This is pretty simple, but I must be missing the obvious. I''ve got a table that''s similar to this: USERS: - id int - username varchar(64) - password varchar(64) - role_id int ROLES: - id int - description varchar(16) I''ve had no troubles doing has_many relationships at all. But I want to map the user.role directly to the role model automatically (which sounds
2006 Apr 28
3
store user id in session or find user id
Hi Im uisng the lgoin generatior that as far as I can tell stores the username in session. I have another table that i need to store the id of the user who creates an entry. (the logged in user) Is it possible to store return the id and store it in session once the user is created. then do somthing like @project.user_id = session[:user].id; or can I perform a search in the product table
2006 Jul 16
9
acl_system help is needed
i found Ezra''s acl_system plugin yesterday and i am trying to figure it out. based on the simple instructions on the site, it does exactly what i need but i''m getting some errors when i try to use it: NoMethodError in UsersController#index You have a nil object when you didn''t expect it! The error occured while evaluating nil.roles i am pretty new to rails and
2006 Feb 16
4
Problems to test controllers which require login
Hi there, I have a quite stupid problem with my testing environment. I''m trying to test my controllers but every controller with a login rewuirement will fail (because there is no logged in user in the session). I realized the conceptual problem behind this, but I''m not able to solve it. What I have done so far: * Login in the test class as described in the Agile Rails Book.
2009 Aug 21
12
What to do before launching v1.0?
I’m launching a rails website, the app is written and works, undoubtedly it’ll be an unmitigated disaster when I launch but none the less I thought I’d least attempt to give myself the best chance of success by asking all the gurus here for some advice – pre launch advice if you like. In an ideal world I’d spend days and hours on all of these things and get it absolutely spot on, but as we all
2011 Mar 30
3
Test errors in fuctional test after adding before_filter :login_required to controller
Hello, I added the "before_filter" to my controllers to require a login of the user. Here''s an example of my Unit Controller with the added before_filter: IN THE ATTACHED FILE When executing the tests with rake test, I get different error messages. To show you my errors, I only executed the unit controller test with the following line: ruby -Itest
2006 Apr 11
9
rails equivalent to asp''s Application object?
In asp you have an Application built-in object, which works just like the Session hash, but it lets you share information among all users of a given application. which is the rails equivalent??? and if there isn''t, how would you implement such a thing ? (there would be concurrency issues to take into account, in fact asp''s application object has some lock and unlock methods
2006 Apr 21
2
newbie q about saving data to mysql
I have a two tables in my DB: users and products and I tried to set up a foreign key relationship between the id field in user and a user_id field in product. Despite redoing my scaffold the user_id does not show up when I go to create a new user. Is that normal? More importantly, how can I save the user id of the logged in user to the user_id field in my product table? Currently my create
2006 Mar 02
8
User Authentication
I''m trying to create a simple authentication system but am failing miserably. I''m (sort of) following the "Logging In" chapter of the Agile book. Ideally, any access to http://example.com/publish (and any of its subdirectories) should redirect to http:/example.com/publish/login when there is no valid session user_id. Code so far:
2010 Dec 09
2
Skip validation on nested attribute
Hi, I have a two models, advert and address. An advert has one address. On my advert form I have a nested form of the address. But I only want to create the nested address depending on the adver kind. how can I skip the nested attribute validation? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2006 Aug 12
2
Ferret Issues
Hi, I have installed the ferret gem (on WIN XP). My search and result view is working, but it comes back with empty results all the time. It seems like ferret is building the index (there is 3 binary files in the index directory). If I add the line: acts_as_ferret :fields =>
2008 Dec 19
3
Recommended way of restricting action permissions?
Hi, I just have a "best practices" question. I''d like to block users that don''t own a particular resource from performing edit/update/ destroy actions on it. Here''s how I currently do it: ## User has many resources, of different types ------- resource_controller.rb ------- before_filter :require_ownership, :only => [:edit, :update, :destroy] ... public