similar to: need help with some ugly code - is there a better way?

Displaying 20 results from an estimated 10000 matches similar to: "need help with some ugly code - is there a better way?"

2008 Sep 11
4
(unknown)
I do not seem to understad what this error is about. Some body help. wrong number of arguments (1 for 2) RAILS_ROOT: C:/INSTAN~1/rails_apps/project/config/.. Application Trace | Framework Trace | Full Trace #{RAILS_ROOT}/app/controllers/user_controller.rb:10:in `authenticate'' #{RAILS_ROOT}/app/controllers/user_controller.rb:10:in `process_login''
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:
2006 Jul 10
1
Redirects and keeping flash
My code that acts if a session has timed out looks like this: reset_session session[:expires_at] = nil # TODO - This flash is never shown, because we redirect maybe? flash[:error] = ''Your session has timed out, please login to continue.'' # An attempt to make flash stick around, not working flash.keep redirect_to :controller => ''security'',
2006 Jul 17
10
getting the user name
Hi I am new to ruby and trying to obtain the user name in the login index.rhtml where I could display "You have logged in [user name]" How could I do this? I have been trying different options after reading the ruby manual but still throw an error. please help -- Posted via http://www.ruby-forum.com/.
2006 Jul 06
4
has_one, belongs_to - I am just not getting it
Let me preface by saying i''m a total noob at ruby/rails. :-) For some reason, I am just not grasping the concept of has_one & belongs_to... I''m working on a project that includes user authentication, and 3 different types of user profiles. User profiles are either "fan", "band", or "venue" objects, and user logins are "user"
2006 Jun 08
2
LoginEngine: undefined method `generate_security_token''
Hi there, I''m trying to set up LoginEngine with Rails 1.1.2 on Ruby 1.8.4 on a Windows XP box and the log is reporting: undefined method `generate_security_token'' for #<User:0x39436a0> Rendering user/signup Rendered user/_edit (0.01600) Rendered user/_password (0.01600) Rails appears to be failing on key = @user.generate_security_token in user_controller.rb in the
2005 May 11
7
1.0.8 Salted hash login generator available
All, Version 1.0.8 of the salted hash login generator is available. This contains a few minor bug fixes with the generator plus some README clarifications. If you are successfully running with the code already, you probably do not need this. Joe
2010 Jan 21
2
nested forms and attr_accessable
Rails 2.3.5 I am working on a nested form that assigns roles to users through a table called clearances. I have attr_acessable turned off globally in an initializer: ActiveRecord::Base.send(:attr_accessible, nil) I have this set in clearance.rb attr_accessible(:description, :effective_from, :role_id, :superceded_after, :user_id) And this is what params looks like after the
2006 Jan 16
4
Creating two records at once
Hi there, I have a User model and a Profile model. A user has_one profile, and a profile belongs_to a user. The profile model contains a user_id column as the foreign key. The problem comes in when I want a user to register. In the user_controller I have a method that creates the user. I also want the profile model to be filled in with the appropriate user_id foreign key (I don''t care
2007 Jul 12
3
Agh, this is annoying. Why is this happening?
My problem: Mock ''Task_1005'' received unexpected message :user_id= with (1) No matter what I do to try to stub that out it will still fail out and give me that message. Here is my spec describe TasksController, "handling POST /tasks" do before(:each) do @task = mock_model(Task, :to_param => "1", :save => true)
2006 Jan 16
1
[roles/users]I give up, please help
> Im testing ruby on rails and to practice i set my mind on making a login > system. because i would come across of regularly made source. > files: user_controller.rb, user.rb > my table layout: users: |id|username|password usertypes: |id|name| (admin, moderator, guest) users_usertypes: |usertype_id|user_id| (+foreign key assocc) > i have this in my user.rb file: class User
2005 Dec 14
1
Problems with testing - error posting to other controller
Hi, I''m trying to test my ad_controller. In order to create an ad, the user has to be logged in, so I have written a login() that logs in a valid user and generates a session[:user_id], like: def login (login="bob", password="atest") post "user/login", :user => { :login => login, :password => password } assert_response 302 # redirect
2006 Feb 21
5
Abstracting ownership verification out of Controller
Right now I have a controller for "events" that belong to a specific user. I only want the creator to be able to edit or delete the event. I''ve got the proper foreign keys set up. I''ve finally arrived at the point where I can take baby steps with code, but looks like my first steps are in flagrant violation of the DRY principle. Here''s what I have so far in
2006 May 17
3
What am I missing?
There''s got to be a simple answer to this... def logout reset_session flash[:notice] = "Logged out" redirect_to :action => ''index'' end The flash never shows up, and doesn''t seem to be in the new session. --Al Evans -- Posted via http://www.ruby-forum.com/.
2011 Dec 16
3
PROBLEN IN AJAX USING RJS
I am using rails 3. I have problem in out put so please tell me my mistake routes ------- entermatch ''/view_article/:user_id/:article_id'' => ''articles#view_article'', :as => :view_article resources :users do resources :articles do resources :comments end end article controller ------------------ def view_article @user =
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 Apr 02
5
Showing current user''s information and saving
Hi, I am logging users in and keeping them in session. The problem I am having is showing only a certain logged in user''s information. In the Adverts_Controler: def show @advert = Advert.find(params[:id]) end I am also having issues with saving an advert for an user: def create @advert = Advert.new(params[:advert]) if @advert.save flash[:notice] = ''Advert
2010 Nov 30
4
Cucumber+Capybara rails 3 issue (Don't know where exactly)
When I''m executing cucumber tests, I noticed that sometimes rails app (in test env.) getting several the same requests (GET or POST) usually around 3, and it doesn''t render anything with empty HTTP status code. Have anyone met something similar to that issue? here is some example of log file: Started POST "/account" for 127.0.0.1 at 2010-11-30 22:34:17 +0200
2007 Dec 04
7
REST bug with form_for
Hi all, I am running on Windows XP sp2 with ruby 1.8.6, and rails 1.2.3 I am using REST, and have this in my view <% form_for(:project, :url => project_path(:user_id => @project.my_user, :id => @project), :html => {:method => :put}) do |f| %> The browser correctly gives <form method="post" action="/users/2/projects/1">
2006 Jan 11
7
Create a relationship with 2 or more tables on 1 insert
userstable: |id|name|password| userdetailstable: |id|col1|col2|col3|user_id| this is my code: [code] def create @user = User.new(@params[''user'']) @userdetail = Userdetail.new(@params[''userdetail'']) if @user.save and @userdetail.save flash[:notice] = "Save succeeded..." redirect_to :action => ''list''