[Rails] Re: My first rspec reports "undefined method `key?' for #"

2008-12-16 Thread Ryan Bigg

There's probably a stack trace associated with that error, try looking  
in that.
-
Ryan Bigg
Freelancer
http://frozenplague.net







On 17/12/2008, at 5:31 PM, 乱翻字典 wrote:

>
> this my first rspec test, it is very simple
> -
>>
> require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
>
> describe Doc do
>  fixtures :docs
>  before(:each) do
>@doc=docs(:yjn_bjy)
>  end
>
>  it "should create a new instance given valid attributes" do
>true
>  end
> end
> < 
> -
> after run "spec -fs spec\models\doc_spec.rb" at cmd line,it report
> this error
> -
>>
> 1)
> NoMethodError in 'Doc should create a new instance given valid
> attributes'
> undefined method `key?' for #
> < 
> -
>
> My environment:
> OS:Windows
> Rails:2.2.2
> RSpec:1.1.11
> rspec-rails:1.1.11
> IDE:Netbeans6.5
> Ruby:1.8.6
>
> I use rspec_scaffold to generate these codes,and really confused about
> this problems.
> Hope for your suggestion!
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Thoughts on controllers

2008-12-16 Thread Ryan Bigg

Take a forum system, hypothetically. You have topics and posts  
controllers which both contain the 7 default RESTful actions. Then you  
realise "Oh, I want to add in a functionality that allows me to split  
topics based on the positioning of certain posts". Ah! A conundrum! So  
what do you do and where do you put it?

Well, since you're going to be splitting a *topic* based on *certain  
posts* I would put this functionality not in the topics controller,  
but the posts controller. The reason for this is because most likely  
we're going to want to split a topic based on a particular post. How  
we split it isn't really important right now. So we create a new  
action called split in our posts controller which has two ways of  
operating, first it will prompt a user how to split a post and then  
it'll undertake the task. So firstly we add it to our routes.rb file:

map.resources :posts, :member => { :split => [:get, :post] }

Notice how we're specifying the :member option here, signifying we  
only want a single post and then after that specifying an array of  
methods that our action will respond to.

When we click the link to go to this split we'll assume that the user  
gets prompted with a form on how they want to split the post (like, do  
they want to split the topic with all the posts after this post,  
before this post and if the new topic should include the post that is  
our candidate) and then when they submit this form it undertakes the  
actual splitting.

Now that's (what I'd like to think of as a) good example of adding a  
"RESTful" action that's not one of "The Seven" to your controller.

A bad example would be going into the topics controller and adding  
actions such as new_post, create_post, edit_post, etc. because post is  
its own resource. The creation, listing, showing, editing and  
destroying of separate resources should be kept separate.

Just a short description :)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] My first rspec reports "undefined method `key?' for #"

2008-12-16 Thread 乱翻字典

this my first rspec test, it is very simple
-
>
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe Doc do
  fixtures :docs
  before(:each) do
@doc=docs(:yjn_bjy)
  end

  it "should create a new instance given valid attributes" do
true
  end
end
<-
after run "spec -fs spec\models\doc_spec.rb" at cmd line,it report
this error
-
>
1)
NoMethodError in 'Doc should create a new instance given valid
attributes'
undefined method `key?' for #
<-

My environment:
OS:Windows
Rails:2.2.2
RSpec:1.1.11
rspec-rails:1.1.11
IDE:Netbeans6.5
Ruby:1.8.6

I use rspec_scaffold to generate these codes,and really confused about
this problems.
Hope for your suggestion!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Thoughts on controllers

2008-12-16 Thread Elliott Golden

Thanks for the the thoughts on this so far.

Here's a further question...

With Rails, I will primarily be building dynamic sites powered by my own 
custom Rails CMS, which I will build in the near future. Also I don't 
plan on these sites or CMS being accessed as services. With this in 
mind, should I even build these using the REST architecture at all, and 
if so what would the benefits be?

Thanks heaps!
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Dependencies.load_paths

2008-12-16 Thread Sijo Kg

Hi
   what is Dependencies.load_paths and placing it in environment.rb?

Thanks in advance
Sijo
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] assign object

2008-12-16 Thread Selva Raj

Hi all,

I am trying to do little bit beyond params.. means I try to assign one
active record object to another object as update attributes both have
same field. Before that I want to remove id field from old object. Is
there way to remove attributes from object and to assign new object??

If any one knows.
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Scaffold leads to OK database, but model empty

2008-12-16 Thread RichardOnRails

Hi Robert,

Thanks for looking carefully at my approach.  I value your warning
that my names for the date fields I defined may be redundant.

> Notice how your "created" and "modified" attributes are redundant with 
> "created_at" and "modified_at."

Every Csv instance is intended to record attributes of a file
discovered in public\data\csv directory. So the "created" field will
record the date the file in question was created.  The created_at
attribute will record the data the instance (and thus the
corresponding database record) was created.  So I believe they are two
different date values.

As far as the date format is concerned, I plan to use (for example)
File.new(filename).ctime.strftime(pattern) in view.

Does that make sense,  or do you think I am confused in this
perception?  Please let me know.

Best wishes,
Richard

On Dec 15, 12:30 pm, Robert Walker 
wrote:
> >>> @csv = Csv.new
> > => # > imported: nil, created_at: nil, updated_at: nil>
>
> One other thing that might be noteworthy...
>
> Notice how your "created" and "modified" attributes are redundant with
> "created_at" and "modified_at." You might want to consider using the
> ones provided by Rails by default. This way you have no additional work
> in updating these standard fields. Rails with take care of them for you.
>
> Then you also have the "imported" attribute. Since this is also a date
> field you might want to follow the Rails convention for naming date and
> time fields by appending "_at" or "_on" so you could have "imported_on"
> if you want a date only or "imported_at" if you want to also record the
> time along with the date.
>
> Also note that the default attributes added by "t.timestamps" in your
> migration will use date and time, but you can always format your view to
> show date only if you want. And, of course, you will need to update the
> value of "imported_at" yourself since it not something Rails can do
> automatically.
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: http://localhost/3000 cant see my pages

2008-12-16 Thread Rick

Graham,

One more time:

localhost:3000 NOT localhost/3000

Rick

On Dec 16, 11:55 am, Graham Okeeffe 
wrote:
> I think I'm going to cry.
>
> I have been trying to get this to work for the last 6 hours and cant get
> anywhere.
>
> My installation was working fine yesterday now I cant get it to work.
>
> I have IIS turned off
> My apache server is turned off
> My firewall is turned off
>
> I have started my server successfully Mongrel but I cant see my project
> of localhost/3000.
>
> I am really at my wits end and fell like giving up
>
> someone please help me
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Thoughts on controllers

2008-12-16 Thread abdul hafeez
Hi Elliott Golden..,

If you want to use Restful you can ,And even if you want to add more actions
you can but they need to be defined as those seven methods only..,

if the controller is small then better to do with out RESTful ..

Enjoy and Gud luck

Regards
hafeez

On Wed, Dec 17, 2008 at 8:52 AM, John Yerhot  wrote:

>
> Personally, I try to keeping my applications restful.  It may require
> me to rethink how I am going to accomplish a task, but I find it
> usually forces the most elegant solution in the end.
>
> That's not so say I haven't added extra actions to my controllers, but
> they really shouldn't have too much clutter in them
>
> My $0.02.
>
> On Dec 16, 8:22 pm, Elliott Golden 
> wrote:
> > I am new to Rails. I have read a couple books and ran through a few
> > tutorials as well. I have been using scaffolding a bit to structure a
> > few projects that I am building for learning purposes. I am curious what
> > your take on adding additional actions to the default RESTful actions in
> > the generated controllers is.
> >
> > Is it best to somehow only use the generated controller actions? Is this
> > even feasible, depending on what your app is trying to accomplish? Or is
> > it fairly common to add numerous custom actions that either expand on
> > the default seven or add completely new functionality to the controller?
> >
> > Thanks for your input.
> > --
> > Posted viahttp://www.ruby-forum.com/.
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: error when installing rails on new linode instance

2008-12-16 Thread Freddy Andersen

which rails
find / -name rails

Is it installed in /usr/local/ ?

do you have /usr/local/bin/ in your path?

echo $PATH

Is rails installed?

gem list

Did you install the gems under a user ? maybe you should have done

sudo gem install rails

Just like on a mac if you use gem install on a none privileged user it
will install the gems in .gem in the users home directory... And most
likely you do not have that directory in your path...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: http://localhost/3000 cant see my pages

2008-12-16 Thread abdul hafeez
Hi Graham..,


As hasan told Your application will be displayed at http://localhost:3000/

And also If you have controller name and action/method name Then the
respective page will be

displayed by 
http://localhost:3000/your_controller_name/your_action_name.


Enjoy and Gud Luck

Regards
hafeez

On Wed, Dec 17, 2008 at 3:30 AM, Hassan Schroeder <
hassan.schroe...@gmail.com> wrote:

>
> On Tue, Dec 16, 2008 at 1:55 PM, Graham Okeeffe
>  wrote:
>
> > My installation was working fine yesterday now I cant get it to work.
>
> > I have started my server successfully Mongrel but I cant see my project
> > of localhost/3000.
>
> Is that a typo? Are you actually looking at http://localhost:3000/ ?
>
> If so, what does "can't see" actually mean, and what's in your log?
>
> --
> Hassan Schroeder  hassan.schroe...@gmail.com
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Thoughts on controllers

2008-12-16 Thread John Yerhot

Personally, I try to keeping my applications restful.  It may require
me to rethink how I am going to accomplish a task, but I find it
usually forces the most elegant solution in the end.

That's not so say I haven't added extra actions to my controllers, but
they really shouldn't have too much clutter in them

My $0.02.

On Dec 16, 8:22 pm, Elliott Golden 
wrote:
> I am new to Rails. I have read a couple books and ran through a few
> tutorials as well. I have been using scaffolding a bit to structure a
> few projects that I am building for learning purposes. I am curious what
> your take on adding additional actions to the default RESTful actions in
> the generated controllers is.
>
> Is it best to somehow only use the generated controller actions? Is this
> even feasible, depending on what your app is trying to accomplish? Or is
> it fairly common to add numerous custom actions that either expand on
> the default seven or add completely new functionality to the controller?
>
> Thanks for your input.
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: updating a record error

2008-12-16 Thread Hassan Schroeder

On Tue, Dec 16, 2008 at 5:53 PM, Maulin Pathare
 wrote:
>
> I have having some trouble with my update statement. I have a page that
> allows users to change their personal information (name,
> password...etc), The update statement seems to execute successfully but
> does not update anything. What am I missing?

>  def update
>Player.update(params[:id],
>{:first_name => params[:first_name],

Per the api doc, ActiveRecord::Base.update
"Updates an object (or multiple objects) and saves it to the database,
if validations pass. The resulting object is returned whether the object
was saved successfully to the database or not."

Are you logging validation errors on this? If not, or just for grins, you
might change the controller to Player.update_attributes! to try to make
the error visible...

Alternatively, does your DB log show any problems?

FWIW,
-- 
Hassan Schroeder  hassan.schroe...@gmail.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] error when installing rails on new linode instance

2008-12-16 Thread jason white
Hello All,
   I have just created a new install of Ubuntu 8.10, and have proceeded to
install all of the necessary packages for Ruby on Rails. I installed ruby,
gems, and rails, but when i run rails -v, i get the following error:

r...@li41-22:~# rails -v
-bash: rails: command not found

any guidance would be greatly appreciated

Jason

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Thoughts on controllers

2008-12-16 Thread Elliott Golden

I am new to Rails. I have read a couple books and ran through a few
tutorials as well. I have been using scaffolding a bit to structure a
few projects that I am building for learning purposes. I am curious what
your take on adding additional actions to the default RESTful actions in
the generated controllers is.

Is it best to somehow only use the generated controller actions? Is this
even feasible, depending on what your app is trying to accomplish? Or is
it fairly common to add numerous custom actions that either expand on
the default seven or add completely new functionality to the controller?

Thanks for your input.
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] updating a record error

2008-12-16 Thread Maulin Pathare

I have having some trouble with my update statement. I have a page that
allows users to change their personal information (name,
password...etc), The update statement seems to execute successfully but
does not update anything. What am I missing?

MODEL CODE
---
class Player < ActiveRecord::Base
  has_many :statistics
  has_many :ladders, :through => :statistics

  validates_presence_of :first_name, :last_name, :login, :password
end


CONTROLLER CODE

  def edit
@player = Player.find(params[:id])
  end

  def update
Player.update(params[:id],
{:first_name => params[:first_name],
:last_name => params[:last_name],
:login => params[:login],
:password => params[:password]})
flash[:notice] = "Personal information updated sucessfully
#{params[:id]}"
redirect_to player_path(@current_player)
  end


VIEW CODE
--
The edit method is called from another view as follows


  <% form_tag(edit_player_path(@player), :method => "get") do %>
<%= submit_tag 'Edit personal information' %>
  <% end %>


EDIT VIEW
--
 Edit personal information 
<%= render :partial => 'form' %>

FORM VIEW
--
<%= error_messages_for 'player' %>
<% form_for(@player) do |f| %>
  
  First Name:
  <%= f.text_field :first_name %>
  
  
  Last Name:
  <%= f.text_field :last_name %>
  
  
  Username:
  <%= f.text_field :login %>
  
  
  Password:
  <%= f.password_field :password %>
  
  
  <%= submit_tag "Save" %>
  
<% end %>
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to setup a default route?

2008-12-16 Thread RichardOnRails

Hi Rick,

> grep documents config/routes.rb ==>  map.resources :documents
> When in doubt, rake it out...
> rake routes

Thanks for the mini-tutorial.  I've started getting my routing spec/
usage working, so at the moment I have no outstanding questions.  But
wait until tomorrow :-)  I just got the beginning of a PayrollApp
working with
- routes,
- xxx_path and, shortly,
- create multiple

If you're interested,  checkout my routes and controller at
http://www.pastie.org/340100.

Best wishes,
Richard

On Dec 16, 4:03 pm, Rick  wrote:
> Hey Richard,
>
> Long time no speak...
>
> On Dec 3, 8:51 pm, RichardOnRails
>
>  wrote:
> > Question:  Is that “map.resources :csvs” at the beginning useless,  or
> > does it serve some purpose?
>
> Here's where I find scaffolding most useful - it gives you a picture
> of how the different RoR components play together.
>
> rails -d postgresql test
> cd test
> script/generate scaffold Document title:string synopsis:string
> body:text author:string
>
> Now you can sniff out one way that MVC splits the processing in RoR
> just by perusing the newly created files built in support of your
> Document model.
>
> But, to your specific question:
>
> grep documents config/routes.rb ==>  map.resources :documents
>
> When in doubt, rake it out...
>
> rake routes
> (in /Users/rick/test)
>               documents GET    /documents
> {:controller=>"documents", :action=>"index"}
>     formatted_documents GET    /documents.:format
> {:controller=>"documents", :action=>"index"}
>                         POST   /documents
> {:controller=>"documents", :action=>"create"}
>                         POST   /documents.:format
> {:controller=>"documents", :action=>"create"}
>            new_document GET    /documents/new
> {:controller=>"documents", :action=>"new"}
>  formatted_new_document GET    /documents/new.:format
> {:controller=>"documents", :action=>"new"}
>           edit_document GET    /documents/:id/edit
> {:controller=>"documents", :action=>"edit"}
> formatted_edit_document GET    /documents/:id/edit.:format
> {:controller=>"documents", :action=>"edit"}
>                document GET    /documents/:id
> {:controller=>"documents", :action=>"show"}
>      formatted_document GET    /documents/:id.:format
> {:controller=>"documents", :action=>"show"}
>                         PUT    /documents/:id
> {:controller=>"documents", :action=>"update"}
>                         PUT    /documents/:id.:format
> {:controller=>"documents", :action=>"update"}
>                         DELETE /documents/:id
> {:controller=>"documents", :action=>"destroy"}
>                         DELETE /documents/:id.:format
> {:controller=>"documents", :action=>"destroy"}
>                                /:controller/:action/:id
>                                /:controller/:action/:id.:format
>
> map.resources :your_model_pluralized gives you many url_for and
> path_for routes that can be used to hook up with
> specific :controller :action [:id].  You'll see examples of use in the
> scaffold generated controller and views.
>
> > Can I shoehorn in a related question?
>
> > I want to add another link in index.html.erb.  I want to RESTfully
> > invoke load_cvs_filenames in the csvs controller.  Is that simple to
> > write?
>
> It's not clear to me what you're after here.  Any more thoughts?
>
> Rick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] db:create & db:migrate issues

2008-12-16 Thread charlieb

Greetings:

I am new to ROR and RadRails. All assistance will always be
appreciated.

My environment:

Windows XP
Ruby 1.8.6
Rails 2.2.2
Aptana Studio, build: 1.2.1.020234
RadRails 1.1.0.200812081651NGT

I created a new ROR Project.

When I attempted to run db:create --trace for the first time I got the
following message:

in C:/RailsApp/chbdepot)
** Invoke db:create (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:create

RadRails did not create chbdepot_development.

I then created chbdepot_development manually and re-ran db:create --
trace. I got the following message:

>rake db:create --trace
(in C:/RailsApp/chbdepot)
** Invoke db:create (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:create
chbdepot_development already exists

This is correct because I created the db manually.

I then ran:

>rake db:migrate --trace
(in C:/RailsApp/chbdepot)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!
undefined method `each' for #
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/mysql_adapter.rb:414:in `tables'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/abstract/schema_statements.rb:330:in
`initialize_schema_migrations_table'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
migration.rb:430:in `initialize'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
migration.rb:394:in `new'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
migration.rb:394:in `up'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
migration.rb:377:in `migrate'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/tasks/databases.rake:
111
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `call'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in
`execute'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in
`execute'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:578:in
`invoke_with_call_chain'
c:/ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in
`invoke_with_call_chain'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:564:in `invoke'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2019:in
`invoke_task'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in
`top_level'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in
`top_level'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in
`standard_exception_handling'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1991:in
`top_level'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1970:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in
`standard_exception_handling'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1967:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/bin/rake:31
c:/ruby/bin/rake:16:in `load'
c:/ruby/bin/rake:16


Thanks,
Charlie

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: faceted browse/filter

2008-12-16 Thread Rajat Garg

Did you find something for addressing this?

On Dec 15, 4:22 pm, Grayson Piercee 
wrote:
> Hello,
>
> Are there any tools for facilitating faceted browsing / filtering for
> A/R? I saw lots of examples for unstructured (solr, sphinx, etc), all
> I'm looking for is something that helps me organize the cardinality of
> lots of different attributes into a filter similar to that on Kayak and
> other sites.
>
> GP
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: text_field_with_auto_complete and Safari browsers

2008-12-16 Thread Shandy Nantz

What I have found out is that when my text_field_with_auto_complete is 
wrapped within a form_remote_tag it doesn't work, however, when I use a 
normal form_tag is works. The problem is that I need the functionality 
that the form_remote_tag gives me. Has anyone else encountered this 
problem and could you share on how to fix it.

Thanks,

-S
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] JOBS

2008-12-16 Thread Rockit

Good day,

I have a website www.CowrieCards.com, online greetings and invitations
with people of color in mind. I want to create a new user experience
and would like to chat with a Ruby developer regarding this. Thanks
much.

--
Cheers ~ Rockit

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Stylesheet Query String

2008-12-16 Thread TomRossi7

I never saw a reply to this post?  Is my question hard or dumb? :)

On Dec 12, 9:53 am, TomRossi7  wrote:
> How does Rails come up with the query string appended to the
> stylesheet tag?
>
> The API does not even show a query string being 
> appended:http://api.rubyonrails.com/classes/ActionView/Helpers/AssetTagHelper
>
> I thought it was a function of the file timestamp, but I have updated
> the file and the querystring still hasn't changed.  I just don't want
> my users to have to refresh to force their browser to see the new
> stylesheet.
>
> Thanks!
> Tom
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: http://localhost/3000 cant see my pages

2008-12-16 Thread Hassan Schroeder

On Tue, Dec 16, 2008 at 1:55 PM, Graham Okeeffe
 wrote:

> My installation was working fine yesterday now I cant get it to work.

> I have started my server successfully Mongrel but I cant see my project
> of localhost/3000.

Is that a typo? Are you actually looking at http://localhost:3000/ ?

If so, what does "can't see" actually mean, and what's in your log?

-- 
Hassan Schroeder  hassan.schroe...@gmail.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to iterate through an instance

2008-12-16 Thread Rob Biedenharn

On Dec 16, 2008, at 4:40 PM, Frederick Cheung wrote:
> Iterate over some_model_instance.attributes ?
>
> Sent from my iPhone
>
> On 16 Dec 2008, at 21:17, Tom Ha 
> wrote:
>
>>
>> Hi there,
>>
>> I have an instance of an object in my database and need to get out
>> every
>> element of it, like this:
>>
>> Example: model = student
>> 
>>
>> firstname = Fred
>> lastname = Williams
>> streetname = NULL
>> city = NULL
>> date of birth = 12.12.1934
>> ...
>> (until there is no more column name left for this model)
>>
>> If it was an array, I'd use: .each { ... }
>>
>> How do I correctly/efficiently cycle through this one?
>>
>> Thank you very much for your help!
>> Tom

Or Student.column_names.each {|column| puts "#{column} =  
#{student.send(column)}" }

You might display something like column.humanize.downcase if you need  
'date of birth' with the spaces.

-Rob

Rob Biedenharn  http://agileconsultingllc.com
r...@agileconsultingllc.com



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] http://localhost/3000 cant see my pages

2008-12-16 Thread Graham Okeeffe

I think I'm going to cry.

I have been trying to get this to work for the last 6 hours and cant get
anywhere.

My installation was working fine yesterday now I cant get it to work.

I have IIS turned off
My apache server is turned off
My firewall is turned off

I have started my server successfully Mongrel but I cant see my project
of localhost/3000.

I am really at my wits end and fell like giving up

someone please help me
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Buttons with different actions... for a single form

2008-12-16 Thread Rob Biedenharn

On Dec 16, 2008, at 4:13 PM, The Neurochild wrote:
> Hello...
>
> I have a form with 3 buttons, each with a different functionality
> concerning to forum user information. Once it's shown in the form, you
> can:
>
> * Modify your information
> * Print your info (via Prawn)
> * Delete the user
>
> But I only have one form, and I need every button to do a different
> action. Can you please help me find something to make it work?
>
> Greetings
>
> The Neurochild

The first one is clearly a submit button, but the other two could be  
link_to_function, button_to_function, link_to_remote, or  
button_to_remote.  Those wouldn't be 'in' the form.  (Actually, the  
Delete the User could be a
   link_to('Delete', user_path(@user), :method => :delete,
   :confirm => "Really delete #...@user.name}?\n(There is no  
undo!)")
or similar.)

You can get the name of the submit input activated, too, if you need  
to make a choice about what happens next.  (I.e., "Complete Order" or  
"Change Shipping Address")

-Rob

Rob Biedenharn  http://agileconsultingllc.com
r...@agileconsultingllc.com



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to iterate through an instance

2008-12-16 Thread Gabriel Laskar

On Tue, Dec 16, 2008 at 10:17 PM, Tom Ha
 wrote:
>
> Hi there,
>
> I have an instance of an object in my database and need to get out every
> element of it, like this:
>
> Example: model = student
> 
>
> firstname = Fred
> lastname = Williams
> streetname = NULL
> city = NULL
> date of birth = 12.12.1934
> ...
> (until there is no more column name left for this model)
>
> If it was an array, I'd use: .each { ... }
>
> How do I correctly/efficiently cycle through this one?

I don't know if its efficient, or right, but ActiveRecode::Base#attributes [1]
seems to do the job

If you already know the fields, you can also do something like that :

[ :firstname, :lastname, ... ].each do |attr|
  val = model.send attr
end

Hope it will help

[1] : http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M002047
-- 
Gabriel Laskar 

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to iterate through an instance

2008-12-16 Thread Tom Ha

Yeah! I guess that will then be something like...

  some_model_instance.attributes.each { ... }

Going to try that...

Thanks, Fred!

(do you ever stop working...? ;-)


-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Toronto Ruby on Rails Project Night - Jan 14th

2008-12-16 Thread Corina



Toronto's Ruby on Rails Project Night returns January 14th to the Rich
Media Institute (Toronto)

http://www.facebook.com/event.php?eid=52410979866

Yes we will have a drink sponsor, yes we have THREE fantastic
presentations lined up...

Details to come, RSVPs appreciated!


Corina :)
http://correlations.wordpress.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to iterate through an instance

2008-12-16 Thread Frederick Cheung

Iterate over some_model_instance.attributes ?

Sent from my iPhone

On 16 Dec 2008, at 21:17, Tom Ha   
wrote:

>
> Hi there,
>
> I have an instance of an object in my database and need to get out  
> every
> element of it, like this:
>
> Example: model = student
> 
>
> firstname = Fred
> lastname = Williams
> streetname = NULL
> city = NULL
> date of birth = 12.12.1934
> ...
> (until there is no more column name left for this model)
>
> If it was an array, I'd use: .each { ... }
>
> How do I correctly/efficiently cycle through this one?
>
> Thank you very much for your help!
> Tom
> -- 
> Posted via http://www.ruby-forum.com/.
>
> >

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Trying to track down an issue in a performance based load test.. using Rails 2.2.2

2008-12-16 Thread Jay McGaffigan
no... Thank you for responding!  It's good just to be able to talk with
someone about it.
I think I will be putting code into rack... Or rather with JRuby I think if
I set it up to have multiple runtimes a mutex is inserted. I'm goign to keep
on pluggin :)

Jay

On Tue, Dec 16, 2008 at 3:19 PM, s.ross  wrote:

>
> Are you open to putting some code in rack? If so, I'd try inserting a
> mutex as early in the request request cycle as possible and see
> whether you can repro the problem with the threading reduced as close
> to single-threaded as possible. If its a threading issue, you've got
> some real detective work ahead of you, but it sounds like you already
> know that.
>
> Sorry not to be encouraging. We're using MRI and Mongrel -- but this
> is, I agree, an important problem.
>
> On Dec 16, 2008, at 6:57 AM, Jay wrote:
>
> >
> > I think it's more multithreaded... we aren't using JQuery just
> > prototype.
> >
> > Most of the time things work but we are seeing errors where it appears
> > the body just disappears.
> >
> > Jay
> >
> > On Dec 15, 10:31 pm, "s.ross"  wrote:
> >> Here's a thought: If it's Ajax and your are POSTing from jQuery,
> >> check
> >> to see you have params. Some clients are sketchy about filling in a
> >> body of a POST by themselves.
> >>
> >> On Dec 15, 2008, at 6:10 AM, Jay wrote:
> >>
> >>
> >>
> >>> I am trying to debug an issue with Rails 2.2.2... I am running a
> >>> load
> >>> test where I am logging in and out 20 users, and I am occasionally
> >>> seeing this error, in my logs:  (see stack trace below)  it appears
> >>> that the body of some of my requests are null... I'm trying to
> >>> figure
> >>> out if a) it's a rails issue, b) is it a jruby/rack issue or c) is
> >>> it
> >>> an issue with caching (which is turned on but I wouldn't think
> >>> should
> >>> be an issue on a login/logout scenario).  any one have any
> >>> thoughts on
> >>> where I Could check to see why the body is null?  I'm off to try and
> >>> turn off caching to see what happens but this issue is a pretty big
> >>> issue and we need to resolve it asap.  We see it in normal usage of
> >>> our website too.  It appears to be timing related but I'm not sure
> >>> why
> >>> or how yet.
> >>
> >>> I'm not necessarily looking for THE answer but any general help of
> >>> "check xxx" would be great.
> >>
> >>> Thanks!
> >>> Jay
> >>
> >>> [#|2008-12-11T16:14:13.299-0500|INFO|sun-appserver9.1|
> >>> javax.enterprise.system.container.web|
> >>> _ThreadID=16;_ThreadName=httpWorkerThread-8081-1;|PWC1412:
> >>> WebModule[]
> >>> ServletContext.log():/!\ FAILSAFE /!\  Thu Dec 11 16:14:13 -0500
> >>> 2008
> >>>  Status: 500 Internal Server Error
> >>>  undefined method `[]' for nil:NilClass
> >>>/Applications/NetBeans/glassfish-v2ur2/domains/domain1/
> >>> applications/j2ee-modules/WebSite/WEB-INF/gems/gems/
> >>> actionpack-2.2.2/
> >>> lib/action_controller/request.rb:597:in
> >>> `clean_up_ajax_request_body!'
> >>>/Applications/NetBeans/glassfish-v2ur2/domains/domain1/
> >>> applications/j2ee-modules/WebSite/WEB-INF/gems/gems/
> >>> actionpack-2.2.2/
> >>> lib/action_controller/request.rb:508:in
> >>> `parse_formatted_request_parameters'
> >>>/Applications/NetBeans/glassfish-v2ur2/domains/domain1/
> >>> applications/j2ee-modules/WebSite/WEB-INF/gems/gems/
> >>> actionpack-2.2.2/
> >>> lib/action_controller/request.rb:441:in `request_parameters'
> >>>/Applications/NetBeans/glassfish-v2ur2/domains/domain1/
> >>> applications/j2ee-modules/WebSite/WEB-INF/gems/gems/
> >>> actionpack-2.2.2/
> >>> lib/action_controller/request.rb:392:in `parameters'
> >>>/Applications/NetBeans/glassfish-v2ur2/domains/domain1/
> >>> applications/j2ee-modules/WebSite/WEB-INF/gems/gems/
> >>> actionpack-2.2.2/
> >>> lib/action_controller/request.rb:30:in `request_method'
> >>>/Applications/NetBeans/glassfish-v2ur2/domains/domain1/
> >>> applications/j2ee-modules/WebSite/WEB-INF/gems/gems/
> >>> activesupport-2.2.2/lib/active_support/memoizable.rb:86:in
> >>> `request_method'
> >>>/Applications/NetBeans/glassfish-v2ur2/domains/domain1/
> >>> applications/j2ee-modules/WebSite/WEB-INF/gems/gems/
> >>> actionpack-2.2.2/
> >>> lib/action_controller/request.rb:40:in `method'
> >>>/Applications/NetBeans/glassfish-v2ur2/domains/domain1/
> >>> applications/j2ee-modules/WebSite/WEB-INF/gems/gems/
> >>> actionpack-2.2.2/
> >>> lib/action_controller/routing/route_set.rb:433:in
> >>> `extract_request_environment'
> >>>/Applications/NetBeans/glassfish-v2ur2/domains/domain1/
> >>> applications/j2ee-modules/WebSite/WEB-INF/gems/gems/
> >>> actionpack-2.2.2/
> >>> lib/action_controller/routing/route_set.rb:386:in `recognize'
> >>>/Applications/NetBeans/glassfish-v2ur2/domains/domain1/
> >>> applications/j2ee-modules/WebSite/WEB-INF/gems/gems/
> >>> actionpack-2.2.2/
> >>> lib/action_controller/dispatcher.rb:182:in `handle_request'
> >>>/Applications/NetBeans/glassfish-v2ur2/domains/domain1/
> >>> applications/j2e

[Rails] How to iterate through an instance

2008-12-16 Thread Tom Ha

Hi there,

I have an instance of an object in my database and need to get out every
element of it, like this:

Example: model = student


firstname = Fred
lastname = Williams
streetname = NULL
city = NULL
date of birth = 12.12.1934
...
(until there is no more column name left for this model)

If it was an array, I'd use: .each { ... }

How do I correctly/efficiently cycle through this one?

Thank you very much for your help!
Tom
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Buttons with different actions... for a single form

2008-12-16 Thread The Neurochild

Hello...

I have a form with 3 buttons, each with a different functionality
concerning to forum user information. Once it's shown in the form, you
can:

* Modify your information
* Print your info (via Prawn)
* Delete the user

But I only have one form, and I need every button to do a different
action. Can you please help me find something to make it work?

Greetings

The Neurochild
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to setup a default route?

2008-12-16 Thread Rick

Hey Richard,

Long time no speak...

On Dec 3, 8:51 pm, RichardOnRails
 wrote:

> Question:  Is that “map.resources :csvs” at the beginning useless,  or
> does it serve some purpose?
>

Here's where I find scaffolding most useful - it gives you a picture
of how the different RoR components play together.

rails -d postgresql test
cd test
script/generate scaffold Document title:string synopsis:string
body:text author:string

Now you can sniff out one way that MVC splits the processing in RoR
just by perusing the newly created files built in support of your
Document model.

But, to your specific question:

grep documents config/routes.rb ==>  map.resources :documents

When in doubt, rake it out...

rake routes
(in /Users/rick/test)
  documents GET/documents
{:controller=>"documents", :action=>"index"}
formatted_documents GET/documents.:format
{:controller=>"documents", :action=>"index"}
POST   /documents
{:controller=>"documents", :action=>"create"}
POST   /documents.:format
{:controller=>"documents", :action=>"create"}
   new_document GET/documents/new
{:controller=>"documents", :action=>"new"}
 formatted_new_document GET/documents/new.:format
{:controller=>"documents", :action=>"new"}
  edit_document GET/documents/:id/edit
{:controller=>"documents", :action=>"edit"}
formatted_edit_document GET/documents/:id/edit.:format
{:controller=>"documents", :action=>"edit"}
   document GET/documents/:id
{:controller=>"documents", :action=>"show"}
 formatted_document GET/documents/:id.:format
{:controller=>"documents", :action=>"show"}
PUT/documents/:id
{:controller=>"documents", :action=>"update"}
PUT/documents/:id.:format
{:controller=>"documents", :action=>"update"}
DELETE /documents/:id
{:controller=>"documents", :action=>"destroy"}
DELETE /documents/:id.:format
{:controller=>"documents", :action=>"destroy"}
   /:controller/:action/:id
   /:controller/:action/:id.:format

map.resources :your_model_pluralized gives you many url_for and
path_for routes that can be used to hook up with
specific :controller :action [:id].  You'll see examples of use in the
scaffold generated controller and views.

> Can I shoehorn in a related question?
>
> I want to add another link in index.html.erb.  I want to RESTfully
> invoke load_cvs_filenames in the csvs controller.  Is that simple to
> write?
>

It's not clear to me what you're after here.  Any more thoughts?


Rick

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] acts_as_taggible_on_steroids

2008-12-16 Thread Grayson Piercee

I'm wondering if it's possible to use acts_as_taggible_on_steroids for
something like the user's age.  What I'm wondering is,

1.  can it do name/value pairs?
2.  can it search on a range?

GP
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: STI and routing

2008-12-16 Thread coxy

Thanks Wally. Think this could work...

On Dec 16, 6:01 pm, Wally Valters  wrote:
> If you name the route you would...
>
> like:
> map.music  ':section/:subsection/:id', :controller =>music', :action
> => 'show'
>
> then you could use
> music_url
> (:action=>'whatever', :section=>'section', :subsection=>'subsection', :id=>1)
>
> On Dec 16, 3:22 am, coxy <3co...@gmail.com> wrote:
>
> > Hello all,
>
> > I have a main model Article, which is subclassed by several others
> > like so:
>
> > ---
> > class Music < Article
> >   class RecordReview < Music; end
> >   class Interview < Music; end
> > end
> > class Film < Article
> >   class Review < Film; end
> >   class Interview < Film; end
> > end
> > ...etc
> > ---
>
> > Doing it this way I can simply call Music.all, or
> > Music::RecordReview.all etc to find relevant articles. For simplicity
> > I've decided to use only one controller ArticlesController. My URL
> > schema is like this:
>
> > ---
> > '/music'
> > '/music/record_reviews'
> > '/music/record_reviews/1'
> > '/music/record_reviews/new'
> > '/music/record_reviews/1/edit'
> > '/film'
> > '/film/reviews'
> > ...etc
> > ---
>
> > So - my question is - does anybody know a clean way to define this in
> > routes.rb, bearing in mind that all requests need to be passed to the
> > ArticlesController, which then needs to determine which type of
> > article we're currently requesting.
>
> > Right now i'm just doing something like this:
>
> > ---
> > map.connect ':section/:subsection/:id', :controller =>
> > 'articles', :action => 'show'
> > ..etc
> > ---
>
> > and then I use a before_filter to determine the type from the :section
> > and :subsection params - which works - but I then don't get any of the
> > url/path helpers generated doing a map.resources so things are getting
> > a bit messy.
>
> > Thanks in advance
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Trying to track down an issue in a performance based load test.. using Rails 2.2.2

2008-12-16 Thread s.ross

Are you open to putting some code in rack? If so, I'd try inserting a  
mutex as early in the request request cycle as possible and see  
whether you can repro the problem with the threading reduced as close  
to single-threaded as possible. If its a threading issue, you've got  
some real detective work ahead of you, but it sounds like you already  
know that.

Sorry not to be encouraging. We're using MRI and Mongrel -- but this  
is, I agree, an important problem.

On Dec 16, 2008, at 6:57 AM, Jay wrote:

>
> I think it's more multithreaded... we aren't using JQuery just
> prototype.
>
> Most of the time things work but we are seeing errors where it appears
> the body just disappears.
>
> Jay
>
> On Dec 15, 10:31 pm, "s.ross"  wrote:
>> Here's a thought: If it's Ajax and your are POSTing from jQuery,  
>> check
>> to see you have params. Some clients are sketchy about filling in a
>> body of a POST by themselves.
>>
>> On Dec 15, 2008, at 6:10 AM, Jay wrote:
>>
>>
>>
>>> I am trying to debug an issue with Rails 2.2.2... I am running a  
>>> load
>>> test where I am logging in and out 20 users, and I am occasionally
>>> seeing this error, in my logs:  (see stack trace below)  it appears
>>> that the body of some of my requests are null... I'm trying to  
>>> figure
>>> out if a) it's a rails issue, b) is it a jruby/rack issue or c) is  
>>> it
>>> an issue with caching (which is turned on but I wouldn't think  
>>> should
>>> be an issue on a login/logout scenario).  any one have any  
>>> thoughts on
>>> where I Could check to see why the body is null?  I'm off to try and
>>> turn off caching to see what happens but this issue is a pretty big
>>> issue and we need to resolve it asap.  We see it in normal usage of
>>> our website too.  It appears to be timing related but I'm not sure  
>>> why
>>> or how yet.
>>
>>> I'm not necessarily looking for THE answer but any general help of
>>> "check xxx" would be great.
>>
>>> Thanks!
>>> Jay
>>
>>> [#|2008-12-11T16:14:13.299-0500|INFO|sun-appserver9.1|
>>> javax.enterprise.system.container.web|
>>> _ThreadID=16;_ThreadName=httpWorkerThread-8081-1;|PWC1412:  
>>> WebModule[]
>>> ServletContext.log():/!\ FAILSAFE /!\  Thu Dec 11 16:14:13 -0500  
>>> 2008
>>>  Status: 500 Internal Server Error
>>>  undefined method `[]' for nil:NilClass
>>>/Applications/NetBeans/glassfish-v2ur2/domains/domain1/
>>> applications/j2ee-modules/WebSite/WEB-INF/gems/gems/ 
>>> actionpack-2.2.2/
>>> lib/action_controller/request.rb:597:in  
>>> `clean_up_ajax_request_body!'
>>>/Applications/NetBeans/glassfish-v2ur2/domains/domain1/
>>> applications/j2ee-modules/WebSite/WEB-INF/gems/gems/ 
>>> actionpack-2.2.2/
>>> lib/action_controller/request.rb:508:in
>>> `parse_formatted_request_parameters'
>>>/Applications/NetBeans/glassfish-v2ur2/domains/domain1/
>>> applications/j2ee-modules/WebSite/WEB-INF/gems/gems/ 
>>> actionpack-2.2.2/
>>> lib/action_controller/request.rb:441:in `request_parameters'
>>>/Applications/NetBeans/glassfish-v2ur2/domains/domain1/
>>> applications/j2ee-modules/WebSite/WEB-INF/gems/gems/ 
>>> actionpack-2.2.2/
>>> lib/action_controller/request.rb:392:in `parameters'
>>>/Applications/NetBeans/glassfish-v2ur2/domains/domain1/
>>> applications/j2ee-modules/WebSite/WEB-INF/gems/gems/ 
>>> actionpack-2.2.2/
>>> lib/action_controller/request.rb:30:in `request_method'
>>>/Applications/NetBeans/glassfish-v2ur2/domains/domain1/
>>> applications/j2ee-modules/WebSite/WEB-INF/gems/gems/
>>> activesupport-2.2.2/lib/active_support/memoizable.rb:86:in
>>> `request_method'
>>>/Applications/NetBeans/glassfish-v2ur2/domains/domain1/
>>> applications/j2ee-modules/WebSite/WEB-INF/gems/gems/ 
>>> actionpack-2.2.2/
>>> lib/action_controller/request.rb:40:in `method'
>>>/Applications/NetBeans/glassfish-v2ur2/domains/domain1/
>>> applications/j2ee-modules/WebSite/WEB-INF/gems/gems/ 
>>> actionpack-2.2.2/
>>> lib/action_controller/routing/route_set.rb:433:in
>>> `extract_request_environment'
>>>/Applications/NetBeans/glassfish-v2ur2/domains/domain1/
>>> applications/j2ee-modules/WebSite/WEB-INF/gems/gems/ 
>>> actionpack-2.2.2/
>>> lib/action_controller/routing/route_set.rb:386:in `recognize'
>>>/Applications/NetBeans/glassfish-v2ur2/domains/domain1/
>>> applications/j2ee-modules/WebSite/WEB-INF/gems/gems/ 
>>> actionpack-2.2.2/
>>> lib/action_controller/dispatcher.rb:182:in `handle_request'
>>>/Applications/NetBeans/glassfish-v2ur2/domains/domain1/
>>> applications/j2ee-modules/WebSite/WEB-INF/gems/gems/ 
>>> actionpack-2.2.2/
>>> lib/action_controller/dispatcher.rb:110:in `dispatch_unlocked'
>>>/Applications/NetBeans/glassfish-v2ur2/domains/domain1/
>>> applications/j2ee-modules/WebSite/WEB-INF/gems/gems/ 
>>> actionpack-2.2.2/
>>> lib/action_controller/dispatcher.rb:120:in `dispatch'
>>>/Applications/NetBeans/glassfish-v2ur2/domains/domain1/
>>> applications/j2ee-modules/WebSite/WEB-INF/gems/gems/ 
>>> actionpack-2.2.2/
>>> lib/action_c

[Rails] Re: More than one submit_tag in a single form

2008-12-16 Thread Frederick Cheung



On Dec 16, 6:17 pm, Ellen B  wrote:

> Yes, I can continue to muck with the CSS to get the link to exactly
> match the SUBMIT button, but I wondered if it's possible to have the
> two SUBMIT buttons going to different actions and how to do it. I'm

Not really. Going to the same url pretty much means it will be the
same action.
You can get the button clicked as a parameter (if i remember correctly
via params[:commit] for a normal submit thing, or you can use 
if you want the submitted parameter to be distinct from the label.

Fred

> not a RoR developer; I'm a UI designer w/ a lot of HTMl/JS experience
> and I'm just trying to improve the usability of an existing (complex)
> RoR application and customize the look & feel for our site. Sadly,
> there's no "RoR for UI Designers Cookbook"
>
> Thanks for any help.
>
> -- EB
>
> (The RoR documentation format is pretty weak, btw. No Search?
> Incidentally, when I google [submit_tag ruby on rails] I 
> gethttp://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html...
> which doesn't document submit_tab. The RoR documentation site sucks --
> no search??
>
> the documentation for submit_tag is 
> athttp://api.rubyonrails.com/classes/ActionView/Helpers/FormTagHelper.h...)
>
> On Dec 16, 12:03 am, Keynan Pratt 
> wrote:
>
> > First let me say that your question sounds stupid, because based on the
> > info you've given us it would be simpler to use multiple forms. However,
> > you need look no farther that the doc 
> > forsubmit_tag.http://api.rubyonrails.com/
>
> > -K
> > --
> > Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Why isn't there a :dependent => false option?

2008-12-16 Thread Robert Walker

James Byrne wrote:
> Robert Walker wrote:
>> I think a better question is, "Why isn't there a :dependent => :deny 
>> option?"
> 
> Because Josh said no.
> 
> http://dev.rubyonrails.org/ticket/3837

That's a good answer, I'll accept that.

Ar Chron wrote:
> we already have a :before_destroy callback to serve your purpose, which 
> is far more powerful -- not every case is as simple as "Don't delete if 
>there are any employees"

This also makes sense. Especially in the context of Rails. Having a 
"deny delete" or "protect from delete" as implemented in other 
frameworks I've used also makes sense in their own right. But, it is 
true that this is more a validation issue than an association issue, so 
also makes sense to be implemented in the context of validation. The 
line can get a bit fuzzy when talking about "relational integrity" since 
it takes both association manipulation (cascade delete and nullify) and 
validation (deny delete) in order to fully implement.
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to log in from console?

2008-12-16 Thread Steven Budrys


On Dec 16, 2008, at 12:21 PM, James Byrne wrote:

>
> Steven Budrys wrote:
>
>>
>> I think you'd be better off creating a second way to log in where you
>> can simply pass normal parameters from the console.
>
> However, that was my problem to begin with, not knowing how to pass
> parameters from the console.


Sorry, I should have been more clear. I meant create a new method that  
took parameters so that you could call it simply by something like

MyController.console_login(name, password)



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Why isn't there a :dependent => false option?

2008-12-16 Thread Ar Chron


> Department
>   has_many :employees, :dependent => :deny

has_many :employees, :dependent => 'something'

indicates what non-default behavior to apply to the :employees...  not 
some behavior related to the :department

we already have a :before_destroy callback to serve your purpose, which 
is far more powerful -- not every case is as simple as "Don't delete if 
there are any employees"
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] [JOB] Sr. Rails Developer, SF - Relo OK | 90-150k

2008-12-16 Thread OSS

Job Title: Senior Rails Developer
Location: San Francisco - Relocation assistance provided
Duration: Full Time/Permanent
Salary: 90-150k DOE

Candidates who have made it to 1st and/or 2nd interviews have:
*** worked for Yahoo, Google, Amazon, Monster, eBay, Ask.com, etc.
*** graduated from a top school: Stanford, MIT, Berkeley, Carnegie
Mellon, Cornell, etc.

Required Skills:

Our client is home to a new type of search that makes it easy to find
subjective information. Starting in early 2008 the company raised seed
financing from a number of premier angel investors and carefully grew
a high-caliber engineering team. Today, the company includes founders
from more than a half-dozen successful startups, four AI Ph.D.s, and
engineers from Silicon Valley's major technology companies.

We are looking for seasoned Rails Developers who can work
cooperatively with backend engineers, product managers, and user
experience researchers in a fast paced, innovation-heavy environment.
The ideal candidate will have strong technical chops combined with an
eye for building user-intuitive web products.

Responsibilities:
* Help define exact product requirements from rough and sometimes
incomplete specifications
* Quickly implement designs in variety of languages and platforms
* Participating in development of database, definitions and front end
systems building

General requirements:
* B.S. in CS or Computer engineering from a leading institution (M.S.
preferred)
* 3+ years direct technical experience in developing web-based
products
* Fluent in Ruby on Rails, HTML, CSS, JavaScript, mySQL, and related
technologies
* Affinity for rapid prototyping
* Flexibility when faced with complex challenges
* The strongest candidates will have proven records at both mature and
early-stage companies
* It's a major plus if you've worked for big name companies such as
Yahoo!, Google, Ask.com, Amazon, etc.

To be considered, please submit your resume along with your salary
requirements to bg @ capitalmarketsp.com

Beau Gould
Executive Advisor
Capital Markets Placement
www.cmp.jobs
Bg @ capitalmarketsp.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Why isn't there a :dependent => false option?

2008-12-16 Thread James Byrne

Robert Walker wrote:
> I think a better question is, "Why isn't there a :dependent => :deny 
> option?"

Because Josh said no.

http://dev.rubyonrails.org/ticket/3837
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to log in from console?

2008-12-16 Thread James Byrne

Steven Budrys wrote:

> 
> I think you'd be better off creating a second way to log in where you
> can simply pass normal parameters from the console.

However, that was my problem to begin with, not knowing how to pass 
parameters from the console.
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] text_field_with_auto_complete and Safari browsers

2008-12-16 Thread Shandy Nantz

I have a text field with auto complete that allows a user to choose a
name from the list and when that name is selected that name is taken out
of the list of available username to select from.

Today I got notification that someone using my app uses Safari and the
described functionality doesn't work in Safari. In order to make it work
I thought I might be able to do some kind of browser detection and then
have it display a normal dropdown instead of the auto complete, and then
I found that won't work because that list is just to big to be displayed
in a normal drop down, which leads me back to the auto complete.

Has anyway got text_field_with_auto_complete to work in a Safari
browser?

Thanks,

-S
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: More than one submit_tag in a single form

2008-12-16 Thread Ellen B

(Woah there, I don't think it sounds stupid. This is a pretty common
sort of thing to want to do in HTML UIs - *without* a separate form
for each.  If you don't know RoR, you wouldn't think to have a single
form for each user listed on the page or whatever; that's not the way
a proficient web developer would approach the problem in conventional
HTML. )

I'm having a similar problem. I'm modifying Redmine. In a form to
create a new bug/issue, there is currently a SUBMIT button to create
the issue and a link to preview the issue. I want the link to be a
button, instead. Here's the code:

<% labelled_tabular_form_for :issue, @issue,
 :html => {:multipart => true, :id =>
'issue-form'} do |f| %>
<%= error_messages_for 'issue' %>

<%= render :partial => 'issues/form', :locals => {:f => f} %>


<%= submit_tag l(:button_create), :class=> 'but mb' %>
<%= link_to_remote l(:label_preview),
   { :url => { :controller => 'issues', :action =>
'preview', :project_id => @project },
 :method => 'post',
 :update => 'preview',
 :with => "Form.serialize('issue-form')",
 :complete => "Element.scrollTo('preview')"
   }, :accesskey => accesskey(:preview), :class =>
'but' %>

<% end %>

Yes, I can continue to muck with the CSS to get the link to exactly
match the SUBMIT button, but I wondered if it's possible to have the
two SUBMIT buttons going to different actions and how to do it. I'm
not a RoR developer; I'm a UI designer w/ a lot of HTMl/JS experience
and I'm just trying to improve the usability of an existing (complex)
RoR application and customize the look & feel for our site. Sadly,
there's no "RoR for UI Designers Cookbook"

Thanks for any help.

-- EB

(The RoR documentation format is pretty weak, btw. No Search?
Incidentally, when I google [submit_tag ruby on rails] I get
http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#M001394
which doesn't document submit_tab. The RoR documentation site sucks --
no search??

the documentation for submit_tag is at
http://api.rubyonrails.com/classes/ActionView/Helpers/FormTagHelper.html#M001537)

On Dec 16, 12:03 am, Keynan Pratt 
wrote:
> First let me say that your question sounds stupid, because based on the
> info you've given us it would be simpler to use multiple forms. However,
> you need look no farther that the doc 
> forsubmit_tag.http://api.rubyonrails.com/
>
> -K
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to log in from console?

2008-12-16 Thread Steven Budrys


On Dec 16, 2008, at 11:43 AM, James Byrne wrote:

>
> Perhaps.  But I would still like to know how to get this to work  
> through
> the console.  I have found a few leads on the web, such as :
> http://snippets.dzone.com/posts/show/600.  But, I am afraid that this
> example does not make a lot of sense to me and appears at first  
> blush to
> be a bit overwrought.



I think you'd be better off creating a second way to log in where you  
can simply pass normal parameters from the console.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: STI and routing

2008-12-16 Thread Wally Valters

If you name the route you would...

like:
map.music  ':section/:subsection/:id', :controller =>music', :action
=> 'show'

then you could use
music_url
(:action=>'whatever', :section=>'section', :subsection=>'subsection', :id=>1)



On Dec 16, 3:22 am, coxy <3co...@gmail.com> wrote:
> Hello all,
>
> I have a main model Article, which is subclassed by several others
> like so:
>
> ---
> class Music < Article
>   class RecordReview < Music; end
>   class Interview < Music; end
> end
> class Film < Article
>   class Review < Film; end
>   class Interview < Film; end
> end
> ...etc
> ---
>
> Doing it this way I can simply call Music.all, or
> Music::RecordReview.all etc to find relevant articles. For simplicity
> I've decided to use only one controller ArticlesController. My URL
> schema is like this:
>
> ---
> '/music'
> '/music/record_reviews'
> '/music/record_reviews/1'
> '/music/record_reviews/new'
> '/music/record_reviews/1/edit'
> '/film'
> '/film/reviews'
> ...etc
> ---
>
> So - my question is - does anybody know a clean way to define this in
> routes.rb, bearing in mind that all requests need to be passed to the
> ArticlesController, which then needs to determine which type of
> article we're currently requesting.
>
> Right now i'm just doing something like this:
>
> ---
> map.connect ':section/:subsection/:id', :controller =>
> 'articles', :action => 'show'
> ..etc
> ---
>
> and then I use a before_filter to determine the type from the :section
> and :subsection params - which works - but I then don't get any of the
> url/path helpers generated doing a map.resources so things are getting
> a bit messy.
>
> Thanks in advance
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to log in from console?

2008-12-16 Thread James Byrne

James Byrne wrote:

s/b

>>> app.post app.user_session_path @params
> => 302
> 

Got to watch where I am snipping from...
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to log in from console?

2008-12-16 Thread James Byrne

James Byrne wrote:

> 
> Evidently I am not getting the form data to the controller.  So, if some 
> kind soul would care to demonstrate to me how this is accomplished 
> within the console then I will be most grateful.
> 

I figured it out.

$ script/console
>> app.new_user_session_path
=> "/user_session/new"
>> @params = { :user_session => { :password => 'mypass', :username => 'myname', 
>> :remember_me => '0' } }
=> {:user_session=>{:remember_me=>"0", :password=>"mypass", 
:username=>"myname"}
>> app.post app.user_session_path @params
=> 200

Ta Daa... we're in.
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to log in from console?

2008-12-16 Thread James Byrne

Daniel wrote:
> It will be easier to debug your app to find out the internal behavior
> of your objects.
> 
> http://www.datanoise.com/ruby-debug
> 
> Daniel

Perhaps.  But I would still like to know how to get this to work through 
the console.  I have found a few leads on the web, such as : 
http://snippets.dzone.com/posts/show/600.  But, I am afraid that this 
example does not make a lot of sense to me and appears at first blush to 
be a bit overwrought.

I think that my main problem at this point is my lack of familiarity 
with some basic Ruby syntax pertaining to hashes or how to construct an 
http request with form data.

If I do this:

$ script/console
>> app.new_user_session_path
=> "/user_session/new

That seems correct. Next I need to fill in the form params which are 
nested in a hash called user_session. This is where I believe that I am 
going off the rails (pardon the pun).  The user_session hash is accessed 
in the create method of the user_sessions_controller thus:

@user_session = UserSession.new(params[:user_session])

:user_session contains three elements, :password, :username, and 
:remember_me. So I tried this:

>> @params = { :user_session => { :password => 'mypass', :username => 'myname', 
>> :remember_me => '0' } }
=> {:user_session=>{:remember_me=>"0", :password=>"mypass", 
:username=>"myname"}}

Which also seem ok to me, given I believe that it is @params that I use 
to pass the form data back.  If I misapprehend that, admittedly a strong 
possibility, then the failure that follows is expected.

Then I do this:

>> app.post app.user_session_path 
==> 200

But, the response code only refers to the re-rendered input page which 
has these errors:

>> app.response
=> ...

2 errors prohibited this user session from being saved
There were problems with the following fields:
  
 Username can not be blank
 Password can not be blank
  

...

Evidently I am not getting the form data to the controller.  So, if some 
kind soul would care to demonstrate to me how this is accomplished 
within the console then I will be most grateful.

Regards,
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Why isn't there a :dependent => false option?

2008-12-16 Thread Robert Walker

I think a better question is, "Why isn't there a :dependent => :deny 
option?"

It's very common to have a relational dependency where you want to deny 
the deletion of an object that has related objects. It would be really 
nice if this referential integrity rule was part of Rails core rather 
than having to write it yourself or use a plugin.

It doesn't seem to me that it would be too difficult to add, if the 
count of the related objects is greater than zero deny the deletion.

Example:

Employee
  belongs_to :department

Department
  has_many :employees, :dependent => :deny

Deny deletion of a department if the department contains one or more 
employees.
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to log in from console?

2008-12-16 Thread Daniel

It will be easier to debug your app to find out the internal behavior
of your objects.

http://www.datanoise.com/ruby-debug

Daniel

On Dec 16, 10:25 am, James Byrne 
wrote:
> I am attempting to investigate the object state during a login process.
> I need instruction in the correct technique to emulate filling out an
> html form and submitting it within the rails console.
>
> Given a login form at /user_session/new with fields :username and
> :password and a submit button.
>
> $ script/console
> ...>> app.new_user_session_path
>
> => "/user_session/new">> @params = { :password => 'mypassword', :username => 
> 'myuser' }
>
> => {:password=>"mypassword", :username=>"myuser"}
>
> Now, how do I submit this to the create action of the
> user_sessions_controller?
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Saving a "final" version of a record.

2008-12-16 Thread Peter De Berdt

On 16 Dec 2008, at 17:29, Pardee, Roy wrote:

> In the olden days we would do this sort of thing with db triggers  
> and a 'journal' table--every UPDATE would result in a record_version  
> field being incremented, and the pre-update version of the rec  
> written out to a separate table.  You can also keep all record  
> versions in one table & put up a view that selects out just the most  
> recent, but that can be problematic perf-wise.  (IIRC, chunks of SAP  
> do the all-versions-in-one-table thing.)
>
> Agree that an AR plugin should be able to handle the journaling--not  
> sure if there is one that does.  I vaguely recall an 'acts as  
> deleteable' or 'acts as archivable' plugin discussed here a while  
> back that seems like similar functionality--not sure if it would get  
> you all the way there.


There's also acts_as_git:
http://www.caboo.se/articles/2008/11/15/new-plugin-acts_as_git

All plugin based solutions have an impact on performance, don't know  
how good or bad acts_as_git does it. Since it uses text files to  
version records and works on a field-by-field basis, I wouldn't get my  
hopes up all too much. Maybe the developer himself can chime in on  
this thread.


Best regards

Peter De Berdt


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Why isn't there a :dependent => false option?

2008-12-16 Thread Brian Hogan

@Ed:

Just leave the :dependent option off completely and nothing happens to
the other records.  That's the default behavior.


On Tue, Dec 16, 2008 at 10:37 AM, Patrick Doyle  wrote:
> On Tue, Dec 16, 2008 at 10:29 AM, Ed Lebert  wrote:
>>
>> I have an "audit" table that records when changes are made to another
>> table.  If a record is destroyed, I don't want all the change audits
>> for that record destroyed or nullified along with it.
>>
> How about :dependent => :nullify, or perhaps not attaching :dependent at all
> to your model which (I am presuming) :has_many of the other model?
>
> --wpd
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Alternative solution to session and global variables

2008-12-16 Thread Hassan Schroeder

On Tue, Dec 16, 2008 at 7:51 AM, The Neurochild  wrote:
>
> ... we have as much 50 session variables inside.

Sounds like a refactoring opportunity :-)

-- 
Hassan Schroeder  hassan.schroe...@gmail.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Substituting single quotes in strings

2008-12-16 Thread Erik Lindblad

Thanks

I did not think about the potential back reference for regexps. Good
catch.

Regards

Erik


On 16 Dec, 17:06, Frederick Cheung  wrote:
> On 16 Dec 2008, at 15:01, Erik Lindblad wrote:
>
>
>
> > Hi
>
> > I want to substitute single quotes in a string but fails unless
> > resorting to overkill (imho) techniques like blocks:
>
> >>> s = "ab'cd"
> > => "ab'cd"
> >>> s.sub("'") {|s| %q{\'} }
> > => "ab\\'cd"
>
> s.sub("'","'")
>
> You need four backslashes because:
> - backslashes have to be escaped in a string literal
> - in the case of a sub/gsub subsitution, a backslash has special  
> meaning (because you can do stuff like s.sub(/(')/, "x\\1x") #=>  
> "abx'xcd"
>
> Fred
>
> > As seen this method works but why can't I do something like
>
> >>> a.sub("'", %q{\'})
> > => "aaabb"
>
> > when
>
> >>> a.sub("'", %q{h})
> > => "aaahbbb"
>
> > works?
>
> > Can someone shed some light on this? Thanks in advance.
>
> > Regards
>
> > Erik
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Why isn't there a :dependent => false option?

2008-12-16 Thread Patrick Doyle
On Tue, Dec 16, 2008 at 10:29 AM, Ed Lebert  wrote:

>
> I have an "audit" table that records when changes are made to another
> table.  If a record is destroyed, I don't want all the change audits
> for that record destroyed or nullified along with it.
>
> How about :dependent => :nullify, or perhaps not attaching :dependent at
all to your model which (I am presuming) :has_many of the other model?

--wpd

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Saving a "final" version of a record.

2008-12-16 Thread Pardee, Roy
In the olden days we would do this sort of thing with db triggers and a 
'journal' table--every UPDATE would result in a record_version field being 
incremented, and the pre-update version of the rec written out to a separate 
table.  You can also keep all record versions in one table & put up a view that 
selects out just the most recent, but that can be problematic perf-wise.  
(IIRC, chunks of SAP do the all-versions-in-one-table thing.)

Agree that an AR plugin should be able to handle the journaling--not sure if 
there is one that does.  I vaguely recall an 'acts as deleteable' or 'acts as 
archivable' plugin discussed here a while back that seems like similar 
functionality--not sure if it would get you all the way there.

From: rubyonrails-talk@googlegroups.com 
[mailto:rubyonrails-t...@googlegroups.com] On Behalf Of Patrick Doyle
Sent: Monday, December 15, 2008 12:26 PM
To: rubyonrails-talk@googlegroups.com
Subject: [Rails] Re: Saving a "final" version of a record.

On Mon, Dec 15, 2008 at 1:13 AM, Michael Kahle 
mailto:rails-mailing-l...@andreas-s.net>> 
wrote:

I'll start by apologizing for the title.  I can't think what to call
this.

I have some Claims that need to be entered, but when they are "closed"
it saves the data from other related tables into the Claim (this could
get messy), so that if the Customer, Registration, or Dealer information
is changed at a later date it will remain the same as when the Claim was
closed.

Is there a preferred method for doing this?  Some kind of plugin or
something?

I understand I could have a separate table for keeping the "archived"
version of the record, but I fear the work to create all new tables and
then storing the record as this other new archive type which is nothing
more than a duplicate of the Claim.

Any thoughts?

P.S. - Ask away, I am probably not explaining this perfectly, but I will
try to elaborate if you are having trouble understanding my challenge.
I wonder if you could implement a "copy-on-write" feature in the Customer, 
Registration, Dealer, etc... tables.  Basically, add a "freeze_record" boolean 
column to those tables and set that to "true" when you need to finalize one of 
those records.  If you ever want/need to update a frozen record, you could 
allocate a new one, scan all of the claims to which this record "belongs_to" 
and point all of those that are not closed to the new record.

This strikes me as an ideal candidate for some sort of plugin that mixes into 
ActiveRecord.  Unfortunately, I haven't the foggiest idea how to implement the 
practical side of this theoretical solution (yet... but I'm learning more every 
day).

--wpd




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Substituting single quotes in strings

2008-12-16 Thread Frederick Cheung


On 16 Dec 2008, at 15:01, Erik Lindblad wrote:

>
> Hi
>
> I want to substitute single quotes in a string but fails unless
> resorting to overkill (imho) techniques like blocks:
>
>>> s = "ab'cd"
> => "ab'cd"
>>> s.sub("'") {|s| %q{\'} }
> => "ab\\'cd"
>

s.sub("'","'")

You need four backslashes because:
- backslashes have to be escaped in a string literal
- in the case of a sub/gsub subsitution, a backslash has special  
meaning (because you can do stuff like s.sub(/(')/, "x\\1x") #=>  
"abx'xcd"

Fred

> As seen this method works but why can't I do something like
>
>>> a.sub("'", %q{\'})
> => "aaabb"
>
> when
>
>>> a.sub("'", %q{h})
> => "aaahbbb"
>
> works?
>
> Can someone shed some light on this? Thanks in advance.
>
> Regards
>
> Erik
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Alternative solution to session and global variables

2008-12-16 Thread The Neurochild

Oh! It's a shame. Sorry to hear that. I was hoping to use some
variable that doesn't use a lot of space in the app. we have as much
50 session variables inside.

Too bad
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Callback when objects connect as a habtm relationship

2008-12-16 Thread Kazim Zaidi
If Product and Category models are in a habtm relationship, i.e.

class Product < ActiveRecord::Base
  has_and_belongs_to_many :categories
end

class Category < ActiveRecord::Base
  has_and_belongs_to_many :products
end

I want a piece of code to be executed every time a product is connected to a
category.
Where do I put this code? Which callback (and on which model) will be
triggered?

Any hints appreciated. Thanks for help.

-- 
- Kazim Zaidi
Blog: http://tuxplayground.blogspot.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Why isn't there a :dependent => false option?

2008-12-16 Thread Ed Lebert

I have an "audit" table that records when changes are made to another
table.  If a record is destroyed, I don't want all the change audits
for that record destroyed or nullified along with it.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] How to log in from console?

2008-12-16 Thread James Byrne

I am attempting to investigate the object state during a login process.
I need instruction in the correct technique to emulate filling out an
html form and submitting it within the rails console.

Given a login form at /user_session/new with fields :username and
:password and a submit button.

$ script/console
...
>> app.new_user_session_path
=> "/user_session/new"
>> @params = { :password => 'mypassword', :username => 'myuser' }
=> {:password=>"mypassword", :username=>"myuser"}

Now, how do I submit this to the create action of the
user_sessions_controller?
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Alternative solution to session and global variables

2008-12-16 Thread Frederick Cheung


On 16 Dec 2008, at 14:49, The Neurochild wrote:

>
> Hello, guys.
>
> I'm using session variables (session[:example]) in my app to do all
> the user session tasks. Additionally I'm also using them to save the
> data from a 3-page sata submission, so when when you click "Submit" on
> the last page, you can send the data from the all the pages. However,
> I have a problem: since I'm using session variables, when going to the
> first page having submitted the data to my database, that remains in
> the forms, as I let it keep them when submitting additional data that
> requires a submit and then back to the form (i.e.: A country's state,
> that triggers an action that allows you to select a city from that
> state).
>
> I tried to use global variables from Ruby, but when another user is
> connected, if the submit data is not completed, he overwrites tthe
> data from the first user's previous pages and when the submission is
> done, the last form submits the data from both.
>
> Resuming, what i'm looking for is a kind of variable that is global,
> but also individual at the same time for each user so it doesn't
> overwrites each other data. is there any kind of variable that let me
> do those things?
>
Nope, either the session or the database.

Fred
> Greetings...
>
> The Neurochild
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Substituting single quotes in strings

2008-12-16 Thread Erik Lindblad

Hi

I want to substitute single quotes in a string but fails unless
resorting to overkill (imho) techniques like blocks:

>> s = "ab'cd"
=> "ab'cd"
>> s.sub("'") {|s| %q{\'} }
=> "ab\\'cd"

As seen this method works but why can't I do something like

>> a.sub("'", %q{\'})
=> "aaabb"

when

>> a.sub("'", %q{h})
=> "aaahbbb"

works?

Can someone shed some light on this? Thanks in advance.

Regards

Erik

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Trying to track down an issue in a performance based load test.. using Rails 2.2.2

2008-12-16 Thread Jay

I think it's more multithreaded... we aren't using JQuery just
prototype.

Most of the time things work but we are seeing errors where it appears
the body just disappears.

Jay

On Dec 15, 10:31 pm, "s.ross"  wrote:
> Here's a thought: If it's Ajax and your are POSTing from jQuery, check  
> to see you have params. Some clients are sketchy about filling in a  
> body of a POST by themselves.
>
> On Dec 15, 2008, at 6:10 AM, Jay wrote:
>
>
>
> > I am trying to debug an issue with Rails 2.2.2... I am running a load
> > test where I am logging in and out 20 users, and I am occasionally
> > seeing this error, in my logs:  (see stack trace below)  it appears
> > that the body of some of my requests are null... I'm trying to figure
> > out if a) it's a rails issue, b) is it a jruby/rack issue or c) is it
> > an issue with caching (which is turned on but I wouldn't think should
> > be an issue on a login/logout scenario).  any one have any thoughts on
> > where I Could check to see why the body is null?  I'm off to try and
> > turn off caching to see what happens but this issue is a pretty big
> > issue and we need to resolve it asap.  We see it in normal usage of
> > our website too.  It appears to be timing related but I'm not sure why
> > or how yet.
>
> > I'm not necessarily looking for THE answer but any general help of
> > "check xxx" would be great.
>
> > Thanks!
> > Jay
>
> > [#|2008-12-11T16:14:13.299-0500|INFO|sun-appserver9.1|
> > javax.enterprise.system.container.web|
> > _ThreadID=16;_ThreadName=httpWorkerThread-8081-1;|PWC1412: WebModule[]
> > ServletContext.log():/!\ FAILSAFE /!\  Thu Dec 11 16:14:13 -0500 2008
> >  Status: 500 Internal Server Error
> >  undefined method `[]' for nil:NilClass
> >    /Applications/NetBeans/glassfish-v2ur2/domains/domain1/
> > applications/j2ee-modules/WebSite/WEB-INF/gems/gems/actionpack-2.2.2/
> > lib/action_controller/request.rb:597:in `clean_up_ajax_request_body!'
> >    /Applications/NetBeans/glassfish-v2ur2/domains/domain1/
> > applications/j2ee-modules/WebSite/WEB-INF/gems/gems/actionpack-2.2.2/
> > lib/action_controller/request.rb:508:in
> > `parse_formatted_request_parameters'
> >    /Applications/NetBeans/glassfish-v2ur2/domains/domain1/
> > applications/j2ee-modules/WebSite/WEB-INF/gems/gems/actionpack-2.2.2/
> > lib/action_controller/request.rb:441:in `request_parameters'
> >    /Applications/NetBeans/glassfish-v2ur2/domains/domain1/
> > applications/j2ee-modules/WebSite/WEB-INF/gems/gems/actionpack-2.2.2/
> > lib/action_controller/request.rb:392:in `parameters'
> >    /Applications/NetBeans/glassfish-v2ur2/domains/domain1/
> > applications/j2ee-modules/WebSite/WEB-INF/gems/gems/actionpack-2.2.2/
> > lib/action_controller/request.rb:30:in `request_method'
> >    /Applications/NetBeans/glassfish-v2ur2/domains/domain1/
> > applications/j2ee-modules/WebSite/WEB-INF/gems/gems/
> > activesupport-2.2.2/lib/active_support/memoizable.rb:86:in
> > `request_method'
> >    /Applications/NetBeans/glassfish-v2ur2/domains/domain1/
> > applications/j2ee-modules/WebSite/WEB-INF/gems/gems/actionpack-2.2.2/
> > lib/action_controller/request.rb:40:in `method'
> >    /Applications/NetBeans/glassfish-v2ur2/domains/domain1/
> > applications/j2ee-modules/WebSite/WEB-INF/gems/gems/actionpack-2.2.2/
> > lib/action_controller/routing/route_set.rb:433:in
> > `extract_request_environment'
> >    /Applications/NetBeans/glassfish-v2ur2/domains/domain1/
> > applications/j2ee-modules/WebSite/WEB-INF/gems/gems/actionpack-2.2.2/
> > lib/action_controller/routing/route_set.rb:386:in `recognize'
> >    /Applications/NetBeans/glassfish-v2ur2/domains/domain1/
> > applications/j2ee-modules/WebSite/WEB-INF/gems/gems/actionpack-2.2.2/
> > lib/action_controller/dispatcher.rb:182:in `handle_request'
> >    /Applications/NetBeans/glassfish-v2ur2/domains/domain1/
> > applications/j2ee-modules/WebSite/WEB-INF/gems/gems/actionpack-2.2.2/
> > lib/action_controller/dispatcher.rb:110:in `dispatch_unlocked'
> >    /Applications/NetBeans/glassfish-v2ur2/domains/domain1/
> > applications/j2ee-modules/WebSite/WEB-INF/gems/gems/actionpack-2.2.2/
> > lib/action_controller/dispatcher.rb:120:in `dispatch'
> >    /Applications/NetBeans/glassfish-v2ur2/domains/domain1/
> > applications/j2ee-modules/WebSite/WEB-INF/gems/gems/actionpack-2.2.2/
> > lib/action_controller/dispatcher.rb:132:in `dispatch_cgi'
> >    /Applications/NetBeans/glassfish-v2ur2/domains/domain1/
> > applications/j2ee-modules/WebSite/WEB-INF/gems/gems/actionpack-2.2.2/
> > lib/action_controller/dispatcher.rb:39:in `dispatch'
> >    /Applications/NetBeans/glassfish-v2ur2/domains/domain1/generated/
> > jsp/j2ee-modules/WebSite/loader/rack/adapter/rails.rb:37:in
> > `serve_rails'
> >    /Applications/NetBeans/glassfish-v2ur2/domains/domain1/generated/
> > jsp/j2ee-modules/WebSite/loader/rack/adapter/rails.rb:44:in `call'
> >    /Applications/NetBeans/glassfish-v2ur2/domains/domain1/generated/
> > jsp/j2ee-modules/WebSite/loader/jruby/rack/rails.rb:

[Rails] Re: .erb invoked unexpectedly

2008-12-16 Thread RichardOnRails

Hi Fred,

As you've done many times,  you pulled my fat out of the fire.

Once again,  thank you very much.

Best wishes,
Richarrd

On Dec 16, 4:16 am, Frederick Cheung 
wrote:
> On Dec 16, 6:03 am, RichardOnRails
>
>  wrote:
> > > Why is the app attempting to render something I don't expect ever to
> > > happen?  (If I do find files,  I'll insert their attributes in the
> > > database and redirect to index.
>
> You typoed :notihing
>
> Fred
>
>
>
> > > Where am I going wrong?
>
> > > Thanks in advance,
> > > Richard
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Alternative solution to session and global variables

2008-12-16 Thread The Neurochild

Hello, guys.

I'm using session variables (session[:example]) in my app to do all
the user session tasks. Additionally I'm also using them to save the
data from a 3-page sata submission, so when when you click "Submit" on
the last page, you can send the data from the all the pages. However,
I have a problem: since I'm using session variables, when going to the
first page having submitted the data to my database, that remains in
the forms, as I let it keep them when submitting additional data that
requires a submit and then back to the form (i.e.: A country's state,
that triggers an action that allows you to select a city from that
state).

I tried to use global variables from Ruby, but when another user is
connected, if the submit data is not completed, he overwrites tthe
data from the first user's previous pages and when the submission is
done, the last form submits the data from both.

Resuming, what i'm looking for is a kind of variable that is global,
but also individual at the same time for each user so it doesn't
overwrites each other data. is there any kind of variable that let me
do those things?

Greetings...

The Neurochild
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Git workflow

2008-12-16 Thread Martin Streicher

Jon Loeliger's book on Git should be in O'Reilly's Rough Cuts very
soon. I am editing the book and am finding it well-written and
informative.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Avoiding Clutter in views

2008-12-16 Thread rishav

Hi guys,

Thanks for the replies. I have tried a bunch of the things mentioned
above but still even with the partials and moving code to the
helpers,I dont like the result.
May be I haven't done things right. But humor me for a thought I had
when thinking about the solution..
I have simple profile page filled up with content from different
models and the page is full of "render" statements.  Is there a more
CMS type solution here.

Like for example in Drupal,(aside from the fact its a little
inflexible) , manages views in a very clean and decoupled manner
from the actual application. It delegates the page content to php
variables Like "side-bar" "content" "footer" which acts like a base
theme and then you can have separate sub themes managing individual
components. The sub themes are combined and put in place in the base
theme to render the final output without (atleast most of the time)
the user telling Drupal.

Can anyone recommend any good Rails / Ruby based CMS?

Thanks
Rishav

On Dec 14, 1:14 pm, Andrew Bloom  wrote:
> Don't forget about helpers. Helpers that take blocks are especially
> useful, it's a really easy way to conditionally display some content
> without cluttering the view.
>
> # Helper
> def is_authorized(action, resource, &block)
>   yield if current_user.permission_check(action, resource)
> end
>
> # View
> <% is_authorized(:edit, @user) do %>
>   <%= link_to "Edit", edit_user_path(@user) %>
> <% end %>
>
> On Dec 13, 3:52 am, Robert Zolkos  wrote:
>
> > Hi Rishav,
>
> > The cleanest way is to try and move as much logic into the models and
> > controllers( depending on the context) and then moving a lot of the
> > repetitive view logic into partials.
>
> > There is an excellent video on this on 
> > RailsCastshttp://railscasts.com/episodes/55-cleaning-up-the-view
>
> > Hope this helps.
>
> > Rob
>
> > On Dec 13, 4:45 pm, "Rishav Rastogi"  wrote:
>
> > > Hi,
>
> > > I have seen that when using rails for big applications especially the ones
> > > with a lot of dynamic content. for example: profile pages in social 
> > > network
> > > apps, newspaper websites etc.
>
> > > TheViewsin such rails apps seem to have a lot ofclutter, lots of render
> > > statements, 'if' statements etc.etc. Is there a way toavoidit or cleaner
> > > way to do it.
>
> > > Thanks,
> > > Rishav
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Rails2.2.2, is it a bug?

2008-12-16 Thread Hassan Schroeder

On Tue, Dec 16, 2008 at 1:36 AM, 浩翔  wrote:

> there is have a error."Attempt to call private method"   ---
> format

See:  -- the
"reported to cause trouble" section includes 'format'.

You might want to rename that attribute of your model.

HTH,
-- 
Hassan Schroeder  hassan.schroe...@gmail.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to get fleximage plugin work on edge?

2008-12-16 Thread Rob Lacey

This is now resolved it seems :)

http://github.com/Squeegy/fleximage/commit/1ed1b457d7c946926b695655395a603b1a1e64a7

RobL

pgdst...@googlemail.com wrote:
> I've also experienced this problem, I need to use new functionality in
> edge rails and this has broken my FlexImage setup. I did try just
> creating an empty 'compile' method but unfortunately this created more
> problems.
>
> Anyone had any joy yet?
>
> RobL
>
> Erik Dahlstrand wrote:
>   
>> Hi all!
>>
>> I have developed an application during the last month as a personal
>> rails learning project (I'm from .NET world). Now I want to make the
>> site public. The application is developed using edge rails because I
>> need the I18n features. The thing is that the fleximage plugin stopped
>> working when I moved to edge. Any help how to fix this would be highly
>> appreciated.
>>
>> This is the log messages when calling the image show action:
>>
>> NoMethodError (undefined method `compile' for #> 0xb5fd9688>):
>> /vendor/rails/actionpack/lib/action_view/template_handler.rb:11:in
>> `call'
>> /vendor/rails/actionpack/lib/action_view/renderable.rb:22:in
>> `_unmemoized_compiled_source'
>> /vendor/rails/activesupport/lib/active_support/memoizable.rb:53:in
>> `compiled_source'
>> /vendor/rails/activesupport/lib/active_support/memoizable.rb:21:in
>> `__send__'
>> /vendor/rails/activesupport/lib/active_support/memoizable.rb:21:in
>> `memoize_all'
>> /vendor/rails/activesupport/lib/active_support/memoizable.rb:18:in
>> `each'
>> /vendor/rails/activesupport/lib/active_support/memoizable.rb:18:in
>> `memoize_all'
>> /vendor/rails/activesupport/lib/active_support/memoizable.rb:13:in
>> `freeze'
>> /vendor/rails/activesupport/lib/active_support/memoizable.rb:66:in
>> `_pick_template'
>> /vendor/rails/actionpack/lib/action_view/base.rb:351:in
>> `_exempt_from_layout?'
>> /vendor/rails/actionpack/lib/action_controller/layout.rb:241:in
>> `__send__'
>> /vendor/rails/actionpack/lib/action_controller/layout.rb:241:in
>> `candidate_for_layout?'
>> /vendor/rails/actionpack/lib/action_controller/layout.rb:255:in
>> `pick_layout'
>> /vendor/rails/actionpack/lib/action_controller/base.rb:864:in
>> `render_without_benchmark'
>> /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:
>> 51:in `render'
>> /vendor/rails/activesupport/lib/active_support/core_ext/
>> benchmark.rb:8:in `realtime'
>> /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:
>> 51:in `render'
>> /vendor/rails/actionpack/lib/action_controller/mime_responds.rb:
>> 135:in `send'
>> /vendor/rails/actionpack/lib/action_controller/mime_responds.rb:
>> 135:in `custom'
>> /vendor/rails/actionpack/lib/action_controller/mime_responds.rb:
>> 164:in `call'
>> /vendor/rails/actionpack/lib/action_controller/mime_responds.rb:
>> 164:in `respond'
>> /vendor/rails/actionpack/lib/action_controller/mime_responds.rb:
>> 158:in `each'
>> /vendor/rails/actionpack/lib/action_controller/mime_responds.rb:
>> 158:in `respond'
>> /vendor/rails/actionpack/lib/action_controller/mime_responds.rb:
>> 107:in `respond_to'
>> /app/controllers/attachments_controller.rb:22:in `show'
>> /vendor/rails/actionpack/lib/action_controller/base.rb:1175:in
>> `send'
>> /vendor/rails/actionpack/lib/action_controller/base.rb:1175:in
>> `perform_action_without_filters'
>> /vendor/rails/actionpack/lib/action_controller/filters.rb:617:in
>> `call_filters'
>> /vendor/rails/actionpack/lib/action_controller/filters.rb:610:in
>> `perform_action_without_benchmark'
>>
>>
>> Kind regards, Erik
>> 
>
> >
>   


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Princely Plugin: get nil.size error

2008-12-16 Thread Brijesh Shah

Hi All,

I want to generate pdf with css. I am using princely plugin.

This is code which I written

 def pdf
   prince = Prince.new()
   html_string = render_to_string(:template =>
'/users/paid_invoice.pdf.erb')
   send_data(
 prince.pdf_from_string(html_string),
 :filename => 'some_document.pdf',
 :type => 'application/pdf'
   )
end

But I am getting error of nil.size


You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.size

RAILS_ROOT: /var/www/sortapp
Application Trace | Framework Trace | Full Trace

/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/streaming.rb:123:in
`send_data'
app/controllers/users_controller.rb:135:in `pdf'

I also used make_and_send_pdf  function but got the same error.
I thought I am getting error in render_to_string function.

Can anyone tell me how can I solve this issues?

Thanks in advance
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Params error with: complex form+multiple models

2008-12-16 Thread Frederick Cheung



On Dec 16, 1:50 am, David Sousa 
wrote:
> Hi Hassan Schroeder,
> thanks for replay it.
>
> So, to solve the problem I had to create a unique ID to each element.
> That was easy I used this code:
>
> <% fields_for "invoice[items_attributes][#{Time.now.tv_usec.to_s}]",
> invoice_item  do |form_invoice_item| -%>
>
If the forms you had right at the beginning only submitted incorectly
because of the duplicate ids then I'd try going back to that original
code and only changing
<%= form_invoice_item.text_field :item %>
to
<%= form_invoice_item.text_field :item, :id =>
"invoice_items_attributes_item_#{invoice_item.id}" %>

Fred
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Little information in mongrel output

2008-12-16 Thread Chirantan

Nice question

On Dec 16, 2:35 pm, Martin Hawkins  wrote:
> I'm currently using MS SQL Server for the first time and am
> successfully connecting to a remote server using ODBC, following the
> excellent guidelines published 
> athttp://wiki.rubyonrails.com/rails/pages/HowtoConnectToMicrosoftSQLSer
>
> I'm used to seeing lots of information in the mongrel screen,
> especially the sql commands which are going to be very important on
> this project as I'm accessing more than one database and some of the
> tables are huge.
> Currently, I'm seeing almost nothing. This is typical output:
>
> Processing MenuController#login (for 127.0.0.1 at 2008-12-15 09:40:58)
> [GET]
> Rendering menu/login
> Completed in 6838ms (View: 24, DB: 0) | 200 OK [http://localhost/menu/
> test]
>
> and that's it. Considering that render was preceded by accessing and
> extracting data from 105 tables, it's scant help.
>
> I'm developing on Ubuntu, using ruby 1.8.6, rails 2.2.2 and mongrel
> 1.1.5 in development mode.  I can give details of the ODBC stack if
> that helps.
>
> Any help gratefully received!!
> thanks
> Martin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Little information in mongrel output

2008-12-16 Thread Chirantan

Thanks. It helped!

On Dec 16, 3:58 pm, Frederick Cheung 
wrote:
> On 16 Dec 2008, at 09:35, Martin Hawkins wrote:
>
>
>
>
>
> > I'm currently using MS SQL Server for the first time and am
> > successfully connecting to a remote server using ODBC, following the
> > excellent guidelines published at
> >http://wiki.rubyonrails.com/rails/pages/HowtoConnectToMicrosoftSQLSer...
> > .
>
> > I'm used to seeing lots of information in the mongrel screen,
> > especially the sql commands which are going to be very important on
> > this project as I'm accessing more than one database and some of the
> > tables are huge.
> > Currently, I'm seeing almost nothing. This is typical output:
>
> > Processing MenuController#login (for 127.0.0.1 at 2008-12-15 09:40:58)
> > [GET]
> > Rendering menu/login
> > Completed in 6838ms (View: 24, DB: 0) | 200 OK [http://localhost/menu/
> > test]
>
> > and that's it. Considering that render was preceded by accessing and
> > extracting data from 105 tables, it's scant help.
>
> Have you set the log level too high ? (config.log_level)
>
> Fred
>
> > I'm developing on Ubuntu, using ruby 1.8.6, rails 2.2.2 and mongrel
> > 1.1.5 in development mode.  I can give details of the ODBC stack if
> > that helps.
>
> > Any help gratefully received!!
> > thanks
> > Martin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Little information in mongrel output

2008-12-16 Thread Martin Hawkins

I've got config.log_level = :debug in environment.rb
Martin

On Dec 16, 10:58 am, Frederick Cheung 
wrote:
> On 16 Dec 2008, at 09:35, Martin Hawkins wrote:
>
>
>
>
>
> > I'm currently using MS SQL Server for the first time and am
> > successfully connecting to a remote server using ODBC, following the
> > excellent guidelines published at
> >http://wiki.rubyonrails.com/rails/pages/HowtoConnectToMicrosoftSQLSer...
> > .
>
> > I'm used to seeing lots of information in the mongrel screen,
> > especially the sql commands which are going to be very important on
> > this project as I'm accessing more than one database and some of the
> > tables are huge.
> > Currently, I'm seeing almost nothing. This is typical output:
>
> > Processing MenuController#login (for 127.0.0.1 at 2008-12-15 09:40:58)
> > [GET]
> > Rendering menu/login
> > Completed in 6838ms (View: 24, DB: 0) | 200 OK [http://localhost/menu/
> > test]
>
> > and that's it. Considering that render was preceded by accessing and
> > extracting data from 105 tables, it's scant help.
>
> Have you set the log level too high ? (config.log_level)
>
> Fred
>
> > I'm developing on Ubuntu, using ruby 1.8.6, rails 2.2.2 and mongrel
> > 1.1.5 in development mode.  I can give details of the ODBC stack if
> > that helps.
>
> > Any help gratefully received!!
> > thanks
> > Martin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Little information in mongrel output

2008-12-16 Thread Frederick Cheung


On 16 Dec 2008, at 09:35, Martin Hawkins wrote:

>
> I'm currently using MS SQL Server for the first time and am
> successfully connecting to a remote server using ODBC, following the
> excellent guidelines published at
> http://wiki.rubyonrails.com/rails/pages/HowtoConnectToMicrosoftSQLServerFromRailsOnLinux
>  
> .
>
> I'm used to seeing lots of information in the mongrel screen,
> especially the sql commands which are going to be very important on
> this project as I'm accessing more than one database and some of the
> tables are huge.
> Currently, I'm seeing almost nothing. This is typical output:
>
> Processing MenuController#login (for 127.0.0.1 at 2008-12-15 09:40:58)
> [GET]
> Rendering menu/login
> Completed in 6838ms (View: 24, DB: 0) | 200 OK [http://localhost/menu/
> test]
>
> and that's it. Considering that render was preceded by accessing and
> extracting data from 105 tables, it's scant help.
>
Have you set the log level too high ? (config.log_level)

Fred
> I'm developing on Ubuntu, using ruby 1.8.6, rails 2.2.2 and mongrel
> 1.1.5 in development mode.  I can give details of the ODBC stack if
> that helps.
>
> Any help gratefully received!!
> thanks
> Martin
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Newbie installing EdgeRails: Error

2008-12-16 Thread MFranzl

> Can you freeze your current version?
>
> rake rails:freeze:gems

Yes. This worked. But not  `rake rails:freeze:edge`.

Anyhow, I've found the problem. It was the ruby version. Together with
rubygems-1.3.1, rake-0.8.3 and rails-2.2.2
the listed ruby versions behaved as follows:

ruby-1.8.6-p111   OK
ruby-1.8.7-p0  failed
ruby-1.8.7-p72 OK

So I guess you run ruby-1.8.7 with a patchlevel greater than zero.

Thanks for the hint!

Michael
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] how to create a new page?

2008-12-16 Thread srikanth

hi   all,

i have implemented a applaction with streams table with tags and
tagging support.

every thing is working fine for me.

Problem is while entering the data in to tables i am able to add all
fields in to  streams table from new.html.erb,except tag name
assigning to this because tag will need id of sream table entry.

Once i done with adding the fields in to sterams table i am using
create button to update in database.Now i got stream id and i want to
assing the tagname to the stream, for this i am planning to open a new
page which is used to add tag name for table entries.
How to create a new page to do this?
if i am wrong give me correct way to do this?
thanks for reading query and any suggestions

regard
Srikanth


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] problem of updating the tag name from new.html.erb ?

2008-12-16 Thread srikanth

Hi All,
i have created tables called streams and tags.
Tags table is to assign the tag name to stream table entries.
to tag support i am using acts_as_taggable_steroids plugin.

if i want to create a new table entry from new.html.erb am able to add
and in the same page i am tring to enter the tag name to the stream
table entry but i could not see it is updating in tag table..

to do this i added piece of code in new.html.erb

   Tags
   <%= f.text_field :name %>
 

But if do edit using edit.html.erb i  able to update the tag table
entry.

how to update the tag table entry in new.html.erb.here i am using
below code to edit the tagname in tag table

   Tags
   <%= f.text_area('tags_as_text') %>
 


thanks for reading the query.

regards
Srikanth


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Pagination caching

2008-12-16 Thread An

Hi everybody,
   I have a list of paginated items using ferret.

Every item could be updated and deleted with an ajax call.

Let's suppose I'm paginating my results 10 by 10. When a user deletes
an item, a frequent action, the results in the page drops to 9, so I
have to rebuild the list doing an additional query.

Do you know if there is a better way to do that? Do you have any
advice?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Rails2.2.2, is it a bug?

2008-12-16 Thread 浩翔


   yesterday, i make a demo with Rails2.2.2.


---
model :  Movie
---
class Movie < ActiveRecord::Base
has_many :releases, :dependent => :destroy
validates_presence_of :title
end


-
model:  Release
-
class Release < ActiveRecord::Base
  belongs_to :movie
  validates_presence_of :movie_id, :format, :released_on

  def to_s
[self.format, released_on.to_s(:short)].join(' - ')
  end
end


---
controller:  release_controller
---
class ReleasesController < ApplicationController
  def show
@release = Release.find(params[:id])

respond_to do |format|
  format.html # show.html.erb
  format.xml  { render :xml => @release }
end
  end
end

--
app/views/release/show.html.erb
--

  Movie:
  <%=h @release.movie_id %>



  Format:
  <%=h @release.format %>



  Released on:
  <%=h @release.released_on %>



<%= link_to 'Edit', edit_release_path(@release) %> |
<%= link_to 'Back', releases_path %>


it's correct,   it works !but , when i modify the show page as
following:



  Movie:
  <%=h @release.movie.title %>



  Format:
  <%=h @release.format %>



  Released on:
  <%=h @release.released_on %>



<%= link_to 'Edit', edit_release_path(@release) %> |
<%= link_to 'Back', releases_path %>


there is have a error."Attempt to call private method"   ---
format


Could u help me ?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Little information in mongrel output

2008-12-16 Thread Martin Hawkins

I'm currently using MS SQL Server for the first time and am
successfully connecting to a remote server using ODBC, following the
excellent guidelines published at
http://wiki.rubyonrails.com/rails/pages/HowtoConnectToMicrosoftSQLServerFromRailsOnLinux.

I'm used to seeing lots of information in the mongrel screen,
especially the sql commands which are going to be very important on
this project as I'm accessing more than one database and some of the
tables are huge.
Currently, I'm seeing almost nothing. This is typical output:

Processing MenuController#login (for 127.0.0.1 at 2008-12-15 09:40:58)
[GET]
Rendering menu/login
Completed in 6838ms (View: 24, DB: 0) | 200 OK [http://localhost/menu/
test]

and that's it. Considering that render was preceded by accessing and
extracting data from 105 tables, it's scant help.

I'm developing on Ubuntu, using ruby 1.8.6, rails 2.2.2 and mongrel
1.1.5 in development mode.  I can give details of the ODBC stack if
that helps.

Any help gratefully received!!
thanks
Martin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Thread deadlock activerecord 2.2.2/ruby 1.8.6/postgres win32

2008-12-16 Thread Charles Duffy

Hello,

I'm trying to run the tests that come with activerecord-2.2.2. I'm using
PostgreSQL 8.3 with the pg driver. Other details:

ruby version: 1.8.6 build 111
platform: windows XP SP2
activerecord version: 2.2.2
activesupport version: 2.2.2
pg version: 0.7.9.2008.10.13
mocha version: 0.9.3

When I run "rake test_postgresql TEST=test\cases\transactions_test.rb, I
get a thread deadlock. The error output is attached.

Some other observations:

* The error only manifests itself when the ruby environment platform is
windows. The tests work perfectly under Linux (at least, with ruby 1.8.6
build 114 rather than 111)
* The platform of the PostgreSQL server machine is irrelevant to the
test outcome.
* Comparing database query logs of a (linux-based) good run with a
(windows-based) bad run shows no relevant differences in the queries
being sent to PostgreSQL, until the failure occurs where the windows log
just stops abruptly.
* The error isn't the result of a database deadlock.

I also tried this with ruby 1.8.7. This doesn't give a deadlock error -
instead it just hangs at the same point.

Any ideas on how to get these tests to run to completion successfully?

Thanks,

Charles Duffy

Attachments:
http://www.ruby-forum.com/attachment/3068/testoutput.txt

-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] STI and routing

2008-12-16 Thread coxy

Hello all,

I have a main model Article, which is subclassed by several others
like so:

---
class Music < Article
  class RecordReview < Music; end
  class Interview < Music; end
end
class Film < Article
  class Review < Film; end
  class Interview < Film; end
end
...etc
---

Doing it this way I can simply call Music.all, or
Music::RecordReview.all etc to find relevant articles. For simplicity
I've decided to use only one controller ArticlesController. My URL
schema is like this:

---
'/music'
'/music/record_reviews'
'/music/record_reviews/1'
'/music/record_reviews/new'
'/music/record_reviews/1/edit'
'/film'
'/film/reviews'
...etc
---

So - my question is - does anybody know a clean way to define this in
routes.rb, bearing in mind that all requests need to be passed to the
ArticlesController, which then needs to determine which type of
article we're currently requesting.

Right now i'm just doing something like this:

---
map.connect ':section/:subsection/:id', :controller =>
'articles', :action => 'show'
..etc
---

and then I use a before_filter to determine the type from the :section
and :subsection params - which works - but I then don't get any of the
url/path helpers generated doing a map.resources so things are getting
a bit messy.

Thanks in advance

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Rails + jQuery and Links

2008-12-16 Thread sshefer

Hi,

I currently have a "save for later" function that effectively allows a
logged in user to save an position for later viewing.  (Similar to the
watch/unwatch function on github).  In my scenario I have a Position
model.  Saved positions are resources that belong to the Position,
using the current_user before creation or deletion to create that user
association.

To do this I am doing a POST directly using the link:

<%= link_to('Save for Later',
position_saved_position_url(@position),
:method => :post, :class => "new_saved_position")-%>

However, in my application.js my code seems to still submit the link
and ignore the "return false;" at the end.

$('.new_saved_position').click(function(){
  $.ajax({
type: "POST",
url: $(this).href,
dataType: "script",
beforeSend: function(xhr) {xhr.setRequestHeader("Accept", "text/
javascript");}
  });
  return false;
});

My question:

By adding ":method => :post" am I altering/tainting the way this
should be done?  I realize that having a direct POST like this is not
Restful - are there better ways of doing this?  While not the topic of
this board - is my jQuery code wrong?

Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Starling and Workling?

2008-12-16 Thread Ramon Tayag

It seems that I was getting the error because I was following old
instructions when I installed it.  I looked around and ended up using
http://github.com/starling/starling/tree/master

Thanks :)
Ramon Tayag



On Tue, Dec 16, 2008 at 4:16 PM, Ramon Tayag  wrote:
> Hi everyone,
>
> I'm trying to get workling+starling to work but I'm getting a
> "uninitialized constant MemCache" error.  When I do require
> 'rubygems'; require 'memcache' in irb I don't get errors though.
> Anyone know what's wrong?
>
> Using Rails 2.3 (edge as of several days ago), ruby 1.8.7 (2008-08-11
> patchlevel 72) [i486-linux]
>
> http://pastie.org/340260
>
> Thanks,
> Ramon Tayag
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: I want to create text box but in run time

2008-12-16 Thread Ahmed Abdelsalam





How about creating a hidden DIV
that include the text box, and make it appears programatically.





Regards,...


Ahmed
Abdelsalam






hyuan wrote:


  text_field_tag

See:

http://api.rubyonrails.com/classes/ActionView/Helpers/FormTagHelper.html

On Dec 15, 12:52 pm, mahmoud_cs  wrote:
  
  
On Dec 15, 2:31 am, Joshua Abbott 
wrote:





  There are two problems with that. One, all that's going to do is output
the text "text_field" not call the method. Second, text_field requires
two arguments object_name and method.
  


  So anyway, use the send method to call the text_field method in the view
and pass in whatever args you need.
  


  # Controller
@a = 'text_field'
  


  # View
<%= send(@a, :object_name, :method) %>
  


  Hope that helps.
  


  -- Joshhttp://iammrjoshua.com
  

unfortunately it didn't work
it display that error                undefined method ` text_field '

  
  

  


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.  To post to this group, send email to rubyonrails-talk@googlegroups.com  To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com  For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---





[Rails] Re: .erb invoked unexpectedly

2008-12-16 Thread Frederick Cheung



On Dec 16, 6:03 am, RichardOnRails
 wrote:

> > Why is the app attempting to render something I don't expect ever to
> > happen?  (If I do find files,  I'll insert their attributes in the
> > database and redirect to index.

You typoed :notihing

Fred
>
> > Where am I going wrong?
>
> > Thanks in advance,
> > Richard
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Starling and Workling?

2008-12-16 Thread Ramon Tayag

Hi everyone,

I'm trying to get workling+starling to work but I'm getting a
"uninitialized constant MemCache" error.  When I do require
'rubygems'; require 'memcache' in irb I don't get errors though.
Anyone know what's wrong?

Using Rails 2.3 (edge as of several days ago), ruby 1.8.7 (2008-08-11
patchlevel 72) [i486-linux]

http://pastie.org/340260

Thanks,
Ramon Tayag

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Upload File Using Form

2008-12-16 Thread Keynan Pratt

see attachment_fu
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: More than one submit_tag in a single form

2008-12-16 Thread Keynan Pratt

First let me say that your question sounds stupid, because based on the 
info you've given us it would be simpler to use multiple forms. However, 
you need look no farther that the doc for submit_tag. 
http://api.rubyonrails.com/

-K
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---