Displaying 20 results from an estimated 8000 matches similar to: "Abstracting ownership verification out of Controller"
2006 Jul 07
4
need help with some ugly code - is there a better way?
Hi,
In my user_controller.rb, I have the following method, which is supposed
to send the user to their profile, dependng on what "role" they are (the
roles correspond to the other controllers: venue, band, fan):
def login
if request.post?
if session[:user_id] = User.authenticate(params[:user][:login],
params[:user][:password])
flash[:message] =
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 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 =
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 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 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
2006 Apr 11
7
Undefined Method
Where can I define the method ''tbluser'' in this error?
NoMethodError in Tblregisteredphone#list
Showing app/views/tblregisteredphone/list.rhtml where line #23 raised:
undefined method `tbluser'' for #<Tblregisteredphone:0x375c778>
Extracted source (around line #23):
20: </font>
21: </td>
22: <td>
23: <%= link_to
2006 Jan 26
4
warning: Object#id will be deprecated; use Object#object_id
Is anybody else getting this warning.
When I change @user.id to @user.User_id I am getting no method definition
present exception. Any thoughts?
Rgds,
--Siva Jagadeesan
http://www.varcasa.com/
My First Rails Project. Powered by Typo and soon by RForum too
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
2006 Aug 13
3
Render nothing; go nowhere
I am building an application that requires a C++ program to access the
Rails web application using POST. Now, I just added user authentication
to the mix and it has made things more interesting.
I''m using basic authentication as shown in the AWDWR and Rails Recipes
books. I can now get my C++ program to submit the user credentials to
the login/login page. All I want the login page
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''
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 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 Apr 04
16
No Method Error
This is the error that keeps appearing. I don''t understand why
"@tblusers" is not correct. Can anyone help?
NoMethodError in Tblregisteredphone#new
Showing app/views/tblregisteredphone/new.rhtml where line #20 raised:
You have a nil object when you didn''t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.each
Extracted
2007 Aug 17
11
[rspec] looking for a simple refresher
I''ve been off the rspec for a few months and I''m trying to get back on it.
1)
Spec::Mocks::MockExpectationError in ''TicketsController handling POST
/tickets should create a new ticket''
Mock ''Ticket_1001'' expected :new with ({}) once, but received it 0 times
./spec/controllers/tickets_controller_spec.rb:16:
script/spec:4:
class
2006 May 31
5
undefined method `redirect_to''
Hi all
I have followed this tute:
http://hivelogic.com/articles/2005/12/01/ruby_rails_lighttpd_mysql_tiger
to get rails running and all is fine except for getting:
undefined method `redirect_to''
when I load my test page.
I have the following in my xx.rhtml:
<%= select :group, :user_id, find_all_groups, {}, {:onclick =>
select_group, :size => find_all_groups.size + 1}
2011 Jun 11
1
Having a problem adding a foreign key
I keep getting this exception "SQLite3::SQLException: no such
column: books.user_id: SELECT "books".* FROM "books" WHERE
("books".user_id = 4)" ,which sounds like there is no user_id in books
table.So i just installed foreigner plugin and added "
t.integer :user_id, :null => false" and
"add_foreign_key(:books, :users)" in book
2008 Jan 30
2
Where can I get "authenticate_with_http_basic"?
Hi,
I just installed Rails 2.0.2
[root@mymachine easyx]# ruby --version
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]
[root@mymachine easyrx]# gem install rails --include-dependencies
Need to update 16 gems from http://gems.rubyforge.org
................
complete
Successfully installed rails-2.0.2
[root@remandev easyrx]#
But I''m getting this error in my restful_authentication
2006 Apr 25
2
agile depot app login failure :(
Hi *,
In an attempt to go back to the drawing board and learn RoR some more -
I have built the depot application from the agile book.
After finishing I tried to create a user for the admin section, however
when ever I go to:
http://localhost:3000/login/add_user
It redirects to the login action, I don''t see the [add user] submit
button??
I am sure this is connected to the
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'',
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