Displaying 20 results from an estimated 100000 matches similar to: "Read session in a view"
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">
2008 Jul 11
1
form_tag and hidden text fields
Hello,
while designing a form with the form_for tag, I m not being able to
hide my text fields. Here is an excerpt of my code :
<% form_for :foo, @foo, :url => { :controller=>"foo",:action =>
"create" } do |f| %>
<tr>
<td class="col2"><%= f.text_field :user_id, :type =>
''hidden'', :value=>current_user.id
2006 Dec 01
3
Sessions in Layered Dispatching
Can you use sessions in layered dispatching? I used them in direct
dispatching without any problems, but switching to layered throws an
error (saying session doesn''t exist).
Sorry if this is a double post, Google Groups isn''t posting my message
for some reason.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this
2008 May 28
15
Help with output
I am having problems trying to get the output to work in an
application I have. Here is the example
THIS GIVES ME THE CORRECT VALUES
<!-- ######## Flooring ######### -->
<% if(params[:flooring]) %>
<tr><td colspan="4"><h2>Flooring</h2></td></tr>
<% for company in @companies
2006 Oct 11
3
Basic Relationship Problem
I''m trying to do a basic relationship and it''s not working the way it
should. The data model is obviously a test database as the fields are
minimal.
In irb I do the following:
>> user = User.create(:name => "shawn")
=> #<User:0x259ceac @errors=#<ActiveRecord::Errors:0x259c3a8
@errors={}, @base=#<User:0x259ceac ...>>,
2006 Nov 17
4
before_destroy and sessions
(Semi-newbie.) I want to ensure a user''s able to destroy only his own
objects. I''ve set session info at login:
session[:user_id] = user.id
Now I try this in the model of my deletable objects:
before_destroy :destroy_your_own
def destroy_your_own
raise "Can''t delete that!" unless session[:user_id] == self.user.id
end
which snags EVERY attempted
2008 Mar 17
9
Render index view and RJS on load?
Hi,
I''ve searched for a while online and been unable to find anything
concerning this.
I have a controller with an index action, which has an index view.
This view renders the index page but also needs to execute some
javascript to show some data (using effects) when the page loads. I
thought I could just create the view and RJS with the same name and
the RJS would be run after the
2008 May 21
2
Replacing ActiveRecordStore::Session with a custom model
Has anyone managed to replace ActiveRecordStore::Session with their
own model?
In the source (http://dev.rubyonrails.org/browser/trunk/actionpack/lib/
action_controller/session/active_record_store.rb) it says you can
override the default by setting
CGI::Session::ActiveRecordStore.session_class = MySessionClass
I have tried doing this in a number of ways but I get all kinds of
weird errors, as
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
2008 Mar 01
15
before_filter strange behaviour on update and create
Hi,
I wrote a authentication script and I''m calling it like this in every
class:
class Blah < ApplicationController
before_filter :auth
def auth
req_perm = Permission.find_by_name("Permission Blah")
access = AccessController.new()
if access.is_logged_in(session.session_id)
if
!access.get_current_user(session.session_id).role.permissions.include?
req_perm
redirect_to
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 =
2007 Oct 16
3
hide is not a function
I''m using FF2 + prototype 1.5.1
this small line is giving me a problem: $$("#splash-
description .buy").hide();
Firebug says this:
$$("#splash-description .buy").hide is not a function
if I use a single $ the the hide() function seems to work...
why is this function now working for the double $$?
Stefan
--~--~---------~--~----~------------~-------~--~----~
2006 Oct 31
1
Help with DRY. I feel like im doing more then I have to.
Throughout my Message controller, I do this a lot:
@message = Message.find(params[:id],:conditions => ["user_id = ?",
@session[''user''].id])
Since you need to authenticate to use this app, is there a way i can
tie the Accounts model in with the Message model so I dont have to pass
in the user_id everytime?
--~--~---------~--~----~------------~-------~--~----~
You
2007 Apr 17
4
close a div when click out of the div
Hi. I have this question: I have a page with more ugual "GIF" (say ?/Help
gif). When I click on one of this giv a "DIV" is showed (one for each gif).
And when a div is showed the last div "showed" there must "hide". Ok, no
problem. I have do it. My problem is that the div that is showed in this
moment must to "hide" when I clink into the document
2007 Nov 25
4
is notify resevered word?
Hi,
When I added this association...
class User < ActiveRecord::Base
has_one :notify
end
...and tried then to update column in User table it will call queries
for notify table automatic?
Output
---------------------------------------------------------------
User Columns (0.041488) SHOW FIELDS FROM `users`
User Load (0.001544) SELECT * FROM `users` WHERE (`users`.`nickname`
=
2006 Sep 23
8
acts_as_rateable plugin help!
Hello,
I am having some trouble figuring out how to use the rateable plugin. i
followed as close as the directions located at
http://www.naffis.com/blog/articles/2006/08/31/rails-ajax-star-rating-system
but i fail at working it.
i am getting this error
You have a nil object when you didn''t expect it!
The error occured while evaluating nil.rating
Extracted source (around line #1):
1:
2006 Sep 27
5
Question about has_one
I have a question about regarding the use of ''has_one'' in this scenario:
Schema:
User
----
id
first_name
last_name
UserMessage
----
user_id
message_id
Message
----
id
Assuming business rules dictate that a Message can have at most ONE User
(let''s assume a message can be created without a user associated to it),
these are my questions:
1) How would I use has_one
2007 Jul 18
3
immediate Descendants not working in IE
Hi, im currently styling a menu using a java script effect which hides
the nested submenus on load, and also shows/hides them on mouseover.
It is working in firefox, using ...
var ul = $("nav").getElementsByTagName("ul")[0];
var lis = ul.immediateDescendants();
I then loop through lis to initially hide all the submenus. This works
fine in firefox, but not in IE. The sub
2006 Oct 19
5
find(:all) and find_all_<etc>
Perhaps I''m an idiot and just don''t get it, and perhaps this question
has been asked a million times before, but I''m not really sure how to go
about searching for an answer to it:
Why does my code Library.find(:all, :conditions => "user_id =
#{session[:user].id}") return [] instead of nil when there are no
results?
--
Posted via
2007 Oct 18
9
with_scope issue
I have the following code:
class User < ActiveRecord::Base
has_many :requests do
def find_active(options = {})
with_scope :find => { :conditions => ["requests.active = ?",
true] } do
find(:all, options)
end
end
end
end
Executing user.requests.find_active results in the following SQL:
SELECT * FROM requests WHERE (( requests.user_id = 10 ) AND
(