Displaying 20 results from an estimated 956 matches for "user_id".
2007 Dec 19
6
thread_pooling sleeping
I''m trying to run a single worker that could perform a periodic task
for a given user.
>From a controller, I imagine something like:
def start_job
MiddleMan.ask_work(:worker => :foo_worker, :worker_method => :perform_task,
:data => { :user_id = current_user.id })
end
def check_job
@status = MiddleMan.ask_status(:worker => :foo_worker)[current_user.id]
end
My worker is something like:
class FooWorker < BackgrounDRb::MetaWorker
set_worker_name :foo_worker
def create(args=nil)
@mutex = Mutex.new
@mutex.synchronize d...
2010 Feb 16
0
Strange routing(?) Issue
...ml => @event }
end
end
# GET /events/1/edit
def edit
@event = Event.find(params[:id])
end
def create
@event = Event.new(params[:event])
# @event.address = Address.new(params[:address])
# @event.address.cr
@event.user_id = current_user.id;
respond_to do |format|
if @event.save
flash[:notice] = ''Event was successfully created.''
format.html { redirect_to(@event) }
format.xml { render :xml => @event, :status
=> :created, :loca...
2009 Nov 09
3
How can I improve a Ruby on Rails code that hast a lot of SQL as strings?
...QL query?
- Maybe there''s a way to get both, the table name and the field name in one
operation. I''m imaging something like Item.voteable_id.for_query
=> "`items`.`voteable`".
- How do I escape code to avoid SQL injection when not in conditions? I''m
using the user_id variable directly in a query and although it''s impossible
for a user to put anything in it, I''d rather escape it properly. In a
condition I would do [''user_id = ?'', user_id], but in a join or a select,
how do I do it?
- Does my use of class constants here make se...
2005 Dec 14
5
inserting multiple rows
I have table which stores multiple entries. Each row has user_id,
game_id and a pick_id. On a page the user has to make load of choices.
All this gets submitted.
the html looks like so:
<input type="hidden" name="game_id" value="3">
<input type="hidden" name="user_id" value="19">
<sele...
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 = ?&q...
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)
Task.stub!(:n...
2010 Nov 30
4
Cucumber+Capybara rails 3 issue (Don't know where exactly)
...uot; =
1061) LIMIT 1
PrivateMessage Load (1.2ms) SELECT DISTINCT(private_messages.id)
FROM "private_messages" LEFT JOIN private_messages_users mu ON
mu.to_id = 1061 WHERE (((mu.private_message_id = private_messages.id
and mu.to_status = ''unread'') or (priv
ate_messages.user_id = 1061 and private_messages.user_status =
''unread'')))
SQL (0.5ms) SELECT COUNT(*) AS count_id FROM "private_messages"
WHERE ("private_messages".user_id = 1061 AND (message_type = ''draft''))
SQL (0.6ms) BEGIN
Person Load (0.9ms) SELECT...
2009 Jul 04
9
prevent orphan records
If I have
belongs_to :user
Do I need to have
validates_presence_of :user_id
?
Does Rails validate the presence of :user_id automatically if I have
belongs_to :user?
In other words, does Rails prevent against creating orphan records that
belong to non-existent users?
Thanks.
--
Posted via http://www.ruby-forum.com/.
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] = "Login successful"
if session[:user_id].role == ''Fan''
redirect_to :controller => ''fan'', :action => ''profile''...
2011 Feb 03
3
R Data Manipulation - Transposing Data by a Given Column, Like User_ID
...analysis-friendly dataframe. See
below for an example, I was unable to use t(x) and I couldn't find a
function with options like PROC TRANSPOSE in SAS.
The ideal solution handles variable quantities of SITE - but beggars can't
be choosers. :-)
Thank you in advance,
Mike
## INPUT DATA
USER_ID<-c(1,1,1,2,2,2,3,3,4)
SITE
<-c("SITE1","SITE2","SITE3","SITE1","SITE2","SITE3","SITE1","SITE2","SITE3")
COUNTS <-c(10,13,22,10,12,12,13,44,99)
RAW<-data.frame(USER_ID,SITE,COUNTS)
RAW
#ANSWER SHO...
2008 Jun 25
0
Rspec routing_spec failing on nested singular resource
...profile_routing_spec seem to be failing because
they can''t match the routes, for example;
# The spec
describe ProfileController do
describe "route generation" do
it "should map { :controller => ''profile'', :action => ''show'',
:user_id => ''1'' } to /user/1/profile" do
route_for(:controller => "profile", :action => "show", :user_id =>
1).should == "/user/1/profile"
end
# The failed spec message
should map { :controller => ''profile'', :ac...
2013 Jan 24
12
group by + sum
Hi.. I need some support...
table:
week_id, user_id, project_id, hours
ex. =>
33, 2, 1, 10
34, 2,1,15
33, 2, 2, 20
35, 3, 1,20
etc.
Want to display a sum of hours per week_id per user_id
I have:
@hours = HourUser.includes(:user).group_by { |h| h.week_id }
@hours.keys.sort.each do |hour|
@hours[hour].collect(&:stunden).sum
Hours are summe...
2008 Apr 18
3
has_many and belongs_to with non-primary foreign keys
Hi,
I''m having a bit of trouble with my first Rails app.
----
I have two tables:
create_table :items do |t|
t.column :created_at, :timestamp
t.column :user_id, :int
t.column :text, :text
end
create_table :users do |t|
t.column :user_id, :int
t.column :name, :string
end
----
I''m trying to use the "user_id" field to link both tables, with each
user "has_many" items, and items "belong_to" users.
----
In my us...
2006 Jan 19
8
I can''t figure out how to solve this one
...| NULL |
auto_increment |
| species_id | int(11) | | | 0
| |
| location_id | int(11) | | | 0
| |
| caught_on | datetime | | | 0000-00-00 00:00:00
| |
| user_id | int(11) | | | 0
| |
| length | int(3) | | | 0
| |
| image | varchar(100) | YES | | NULL
| |
| created_at | datetime | YES | | NULL...
2006 Apr 02
5
Showing current user''s information and saving
...:
def create
@advert = Advert.new(params[:advert])
if @advert.save
flash[:notice] = ''Advert was successfully created.''
redirect_to :action => ''list''
else
render :action => ''new''
end
end
How do I get the user_id from the session and use it in above functions
to only show users''s adverts and to pass user_id to the create function
to create an advert for the logged in user?
--
Posted via http://www.ruby-forum.com/.
2009 Jan 26
5
Please help with a routing problem
Hi All
I''m having some issues with the following routes problem.
The routes.rb file ...
map.resources :users
map.connect ''/users/view_payments/:user_id'', :controller =>
''users'', :action => ''view_payments''
The users_controller.rb file ...
def view_payments
@user = User.find[:params[:user_id]]
@payments = @user.payments
end
The routes list from a rake routes ...
/users/view_paymen...
2009 Apr 03
3
plyr and table question
Dear all,
I'm puzzled by the following example inspired by a recent question on
R-help,
cc <- textConnection("user_id website time
20 google 0930
21 yahoo 0935
20 facebook 1000
25 facebook 1015
61 google 0940")
d <- read.table(cc, head=T) ; close(cc)
table(d$user_id) # count the occurrences
# now I'd like to...
2007 Nov 25
4
is notify resevered word?
...User Columns (0.041488) SHOW FIELDS FROM `users`
User Load (0.001544) SELECT * FROM `users` WHERE (`users`.`nickname`
= ''jamal'') LIMIT 1
SQL (0.000373) BEGIN
SQL (0.001843) SHOW TABLES
User::Notify Load (0.001113) SELECT * FROM `user_notifies` WHERE
(user_notifies.user_id = 1) LIMIT 1
User::Notify Load (0.001009) SELECT * FROM `user_notifies` WHERE
(user_notifies.user_id = 1) LIMIT 1
User::Notify Load (0.000996) SELECT * FROM `user_notifies` WHERE
(user_notifies.user_id = 1) LIMIT 1
User::Notify Load (0.000862) SELECT * FROM `user_notifies` WHERE
(user_n...
2009 Jul 04
12
save! not allowed after validates_uniqueness
I have this in a model
validates_uniqueness_of :aspect, :scope => :user_id
In an instance method of the same model I have "save!" but I don''t touch
the :aspect attribute in that instance method at all.
Whenever that save! command is run however I get this error:
ActiveRecord::RecordInvalid: Validation failed: Aspect has
already been taken
I d...
2005 Dec 23
4
OO model style: inheritance
...ying to develop a small gallery app. Since I
would like to add more features in future I am trying
to design a clean OO architecture of my models:
The base object should be NODE. All other objects
extend NODE, those are GALLERY and IMAGE (a GALLERY
consists of 0..* IMAGEs). Each NODE has an owner
(user_id) plus some default fields like created_on and
updated_on. Futhermore there is an object COMMENT
which can be attached to any object that extends NODE
(belongs_to NODE).
According to this design I modeled the db schema as
follows:
CREATE TABLE `nodes` (
`id` int(11) NOT NULL auto_increment,
`u...