[Rails] count a occurence of given attribute

2008-12-30 Thread Ishara Gunathilake
hi,,
i have a two tables named "agents" and "confirm_clients"
in confirm_clients columns
t.column :client_id, :string
t.column: agent_id, :string
t.column:confirm, :boolean

agents
t.column :agent_id, :string
t.column :rank, :integer

i want to count the occurence of each agent_id ,which the
confirm boolean is "true" and i want to save that count number
in the rank column of agents table.as an example

if confirm_clients table agent_id=agent1 has 4 boolean true rows so i want
to save 4 in
the agents table rank column,corresponding agent1s row.plz can anyone help
me to
solve this problem

--~--~-~--~~~---~--~~
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 render more than one partial?

2008-12-30 Thread Zhao Yi

I want to render more than one partial in this code:

render :partial => 'project_version'

how can I do this?
-- 
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: Validation Problem

2008-12-30 Thread emarthinsen

Ah, I just figured it out!

As an aside, and I'm not sure if anyone else notices the same thing,
but it seems like the easiest way for me to solve my own problem is to
ask for help. Never fails.

The issue, in case someone else runs into it, was that I had
accidentally created a new method on my class called "zipcode" (it
returned a ZipCode object, where the zipcode is a string). Somehow,
perhaps based on whether or not zipcode was set, the validation was
using the string sometimes and the object the rest of the time (yes,
yes, I know strings are objects too). This is why my results were
erratic.

Regards,
Eric

On Dec 31, 12:56 am, emarthinsen 
wrote:
> Hello-
>
> I'm trying to do something pretty basic - validate a form field
> against a regex. Here's the line of my model that adds the validation:
>
> validates_format_of :zipcode, :with => /\d{5}(-\d{4})?/, :message =>
> 'is failing the regex'
>
> When I enter the value "12345" into the form field, it comes back and
> tells me that "Zipcode is failing the regex". What's odd is that I've
> gotten sporadic success, where the validations will pass - sometimes
> with values that failed previously.
>
> I feel confident of the regex itself and testing it in IRB yields the
> results I would expect. Once I use it in the validation, then it stops
> working.
>
> Does anyone know what might be going on? Failing that, any ideas for
> where to start troubleshooting this would be appreciated.
>
> Regards,
> Eric
--~--~-~--~~~---~--~~
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 with downloading Ziya plugin

2008-12-30 Thread Dharmdip Rathod

hello ,
i am trying to download Ziya plugin from

ruby script/plugin install
svn://rubyforge.org/var/svn/liquidrail/plugins/ziya/trunk

i have tried other url's but not able to download.Is there any
alternative ? I do not want to download directly from GITHUB.com i want
to download from command prompt.

Help !
-- 
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] Presenters in Rails

2008-12-30 Thread Sijo Kg

Hi
   Could anybody please explain what are presenters in Rails and how
they are used?

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] Validation Problem

2008-12-30 Thread emarthinsen

Hello-

I'm trying to do something pretty basic - validate a form field
against a regex. Here's the line of my model that adds the validation:

validates_format_of :zipcode, :with => /\d{5}(-\d{4})?/, :message =>
'is failing the regex'

When I enter the value "12345" into the form field, it comes back and
tells me that "Zipcode is failing the regex". What's odd is that I've
gotten sporadic success, where the validations will pass - sometimes
with values that failed previously.

I feel confident of the regex itself and testing it in IRB yields the
results I would expect. Once I use it in the validation, then it stops
working.

Does anyone know what might be going on? Failing that, any ideas for
where to start troubleshooting this would be appreciated.

Regards,
Eric
--~--~-~--~~~---~--~~
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 update table column?

2008-12-30 Thread Craig Demyanovich
Here's a more specific URL:
http://guides.rails.info/migrations.html#_changing_migrations .

Craig

On Wed, Dec 31, 2008 at 12:31 AM, Craig Demyanovich
wrote:

> Generally, don't edit migrations. Instead, write a new one. See
> http://guides.rails.info/migrations.html for more details.
>
> Regards,
> Craig
>
>
> On Wed, Dec 31, 2008 at 12:21 AM, Zhao Yi <
> rails-mailing-l...@andreas-s.net> wrote:
>
>>
>> There is a table existed in sqlite3 database. I want to change a column
>> type in this table. I modified the file
>> db/migrate/20081229_create_project.rb and run "rake db:migrate". But
>> it doesn't update the table. How can I update the table with the new
>> definition.
>> --
>> 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 update table column?

2008-12-30 Thread Craig Demyanovich
Generally, don't edit migrations. Instead, write a new one. See
http://guides.rails.info/migrations.html for more details.

Regards,
Craig

On Wed, Dec 31, 2008 at 12:21 AM, Zhao Yi
wrote:

>
> There is a table existed in sqlite3 database. I want to change a column
> type in this table. I modified the file
> db/migrate/20081229_create_project.rb and run "rake db:migrate". But
> it doesn't update the table. How can I update the table with the new
> definition.
> --
> 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] How to update table column?

2008-12-30 Thread Zhao Yi

There is a table existed in sqlite3 database. I want to change a column
type in this table. I modified the file
db/migrate/20081229_create_project.rb and run "rake db:migrate". But
it doesn't update the table. How can I update the table with the new
definition.
-- 
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] automatically load subdirectories under app/models

2008-12-30 Thread Sijo Kg

Hi
   I have found the the below code in environment.rb Here used
subdirectories to better organize files

Dependencies.load_paths += [
  File.join(RAILS_ROOT, "app/models/Dir1"), File.join(RAILS_ROOT,
"app/models/Dir2")
]

What I understood is Rails includes /app/models in the load_path
automatically however it does not include subdirectories. Is it right? I
would like to know there is a better way on handling that, either by
generically loading all subdirectories or by having 1 file in the
app/models directory load the files in the subdirectory

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] Re: Forms fields pre-populating w/ first record's values

2008-12-30 Thread Clem Rock

Thanks for getting back to me on this.

Here's my controller method:

def create_user
if request.post?
  @user = User.new(params[:user])
  if @user.save
flash[:notice] = "User has been added."
flash.keep
redirect_to :controller => 'admin', :action => 'list_users', :id 
=> @user.id, :page => params[:page]
  end
end
  end


Thanks again

Ryan Bigg wrote:
> form_tag does not tag a string as an argument.
> 
> Could you show us your controller please?
> 
> Also, it may help you if you read 
> http://guides.rubyonrails.org/getting_started_with_rails.html
>   first.
> -
> Ryan Bigg
> Freelancer
> http://frozenplague.net

-- 
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: uploading csv

2008-12-30 Thread Rajkumar Surabhi

Vishwanath Nayak wrote:
> Hi,
> 
> You may want to upload the file initially through AJAX, parse it and 
> display
> the output for the user to validate.
> If the user submits the same, you can upload the same parsed value 
> rather
> than re parsing the whole file all together.
> 
> -NAYAK
> 
> On Tue, Dec 30, 2008 at 6:26 PM, Rajkumar Surabhi <

thanks for ur reply... but i dont know how to do it as iam new bee to 
rails.iam aware of ajax and parsing.. is there any websites if plesae 
sugest them or if u have code plesae send 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: Add all metods in ssl_required

2008-12-30 Thread Ryan Wilson

I'm concerned this may not be the best way to go.

in my /app/controllers/application.rb file i've added

def ssl_required?
return false if ENV['RAILS_ENV'] == true
end

So that I can still run my application on webrick without https in 
development mode.

But, when I want ssl_required to work on all my controllers and utilize 
the method below, my ssl_required? method in the application helper 
doesn't function as intended. the ssl_required in the individual 
controller takes precedence.

it is too bad one can't just add

ssl_required :all


Does anyone know how to solve both problems in the best way possible?

Thank you!



Pål Bergström wrote:
> Izidor Jerebic wrote:
>> You can define a protected method in your controller, which will make
>> every action in this controller and all its subclasses only available
>> through ssl:
>> 
>>def ssl_required?
>>  true
>>end
>> 
>> 
>> izidor
>> 
>> 
>> On 5.9.2008, at 16:29, P�l Bergstr�m wrote:
> 
> Thanks :-)

-- 
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: A question about ajax

2008-12-30 Thread Zhao Yi

I know what the problem. I set up a wrong update value in observe_field 
element.
-- 
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: Ansuz CMS

2008-12-30 Thread Ryan Bigg

Looks good, 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: Ansuz CMS

2008-12-30 Thread knewter

oops, link http://ansuzcms.com/pages/features

On Dec 30, 9:17 pm, Ryan Bigg  wrote:
> The code for the forums controller looks suspiciously like Beast's.  
> Perhaps a little bit of attribution credit wouldn't go astray?
> -
> Ryan Bigg
> Freelancerhttp://frozenplague.net
>
> On 31/12/2008, at 1:34 PM, knewter wrote:
>
>
>
> > Hello everyone,
>
> > I just wanted to introduce Ansuz (a rails-based Content Management
> > System, sort of aiming for the wordpress-y space for the rails jet
> > set).  It's BSD licensed, and you can find it athttp://www.ansuzcms.com
> > orhttp://github.com/knewter/ansuz/tree/master.  There was an article
> > in the 2008 Advent Calendar about it, and Akita mentioned it once in
> > his blog, but other than that I don't believe it's received any
> > visibility whatsoever.
>
> > It does have extensive plugin support using engines, theming
> > capabilities thanks to theme_support (as well as a way to install
> > themes from the master theme repository at ansuzcms.com from within
> > the admin interface).  It also has a crowdsound widget in the admin,
> > so anyone using it ever can just easily report issues or feature
> > suggestions.  We've got a lighthouse if you find a bug, also linked
> > from within the admin interface.  I'm constantly sitting in #ansuz on
> > FreeNode, as well as some other users and developers, available for
> > support / to compliment your haircut.  I'll talk you through
> > installing it, whatev.
>
> > It's been successfully run in a host of environments, my ubuntu/mysql
> > to Lex's AIX/DB2, on the mac, and I think windows (shudder).  It
> > currently hosts the ansuzcms.com site as well as my company's site at
> >http://www.isotope11.com.  If anyone ever wants to talk about it or
> > learn how parts of it work, or be walked through it step by step, or
> > whatever...we're here :)  It's got a decent number of plugins as well.
>
> > Anyway, hoping some people will join in the development.  Have a happy
> > new year's.
>
> > Josh Adams
> > isotope11
> >http://www.isotope11.com
>
> > PS - at first I sent this to the really old rails mailing list that's
> > been dead for two years-ish.  Oops.
--~--~-~--~~~---~--~~
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: Ansuz CMS

2008-12-30 Thread knewter

I've attributed the forums in the features section to savage_beast.  I
am aware that savage_beast is a clone of beast, and intend that
attribution to trickle upwards.

I really should update it to use aep_beast from
http://blog.aenima.pl/2008/12/4/aep-beast-a-modern-beast-forum-fork I
think.

-Josh

On Dec 30, 9:17 pm, Ryan Bigg  wrote:
> The code for the forums controller looks suspiciously like Beast's.  
> Perhaps a little bit of attribution credit wouldn't go astray?
> -
> Ryan Bigg
> Freelancerhttp://frozenplague.net
>
> On 31/12/2008, at 1:34 PM, knewter wrote:
>
>
>
> > Hello everyone,
>
> > I just wanted to introduce Ansuz (a rails-based Content Management
> > System, sort of aiming for the wordpress-y space for the rails jet
> > set).  It's BSD licensed, and you can find it athttp://www.ansuzcms.com
> > orhttp://github.com/knewter/ansuz/tree/master.  There was an article
> > in the 2008 Advent Calendar about it, and Akita mentioned it once in
> > his blog, but other than that I don't believe it's received any
> > visibility whatsoever.
>
> > It does have extensive plugin support using engines, theming
> > capabilities thanks to theme_support (as well as a way to install
> > themes from the master theme repository at ansuzcms.com from within
> > the admin interface).  It also has a crowdsound widget in the admin,
> > so anyone using it ever can just easily report issues or feature
> > suggestions.  We've got a lighthouse if you find a bug, also linked
> > from within the admin interface.  I'm constantly sitting in #ansuz on
> > FreeNode, as well as some other users and developers, available for
> > support / to compliment your haircut.  I'll talk you through
> > installing it, whatev.
>
> > It's been successfully run in a host of environments, my ubuntu/mysql
> > to Lex's AIX/DB2, on the mac, and I think windows (shudder).  It
> > currently hosts the ansuzcms.com site as well as my company's site at
> >http://www.isotope11.com.  If anyone ever wants to talk about it or
> > learn how parts of it work, or be walked through it step by step, or
> > whatever...we're here :)  It's got a decent number of plugins as well.
>
> > Anyway, hoping some people will join in the development.  Have a happy
> > new year's.
>
> > Josh Adams
> > isotope11
> >http://www.isotope11.com
>
> > PS - at first I sent this to the really old rails mailing list that's
> > been dead for two years-ish.  Oops.
--~--~-~--~~~---~--~~
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: Ansuz CMS

2008-12-30 Thread knewter

I absolutely used the savage beast plugin.  It is in vendor/plugins.
I copied over the controller to the main app to fix a few ansuz-
specific issues in it.

Sorry if you felt I was leading you astray.  Should I prominently
credit it if my project uses it?  Where should I place this credit?
I'm just trying to make sure I do alright :)

-Josh

On Dec 30, 9:17 pm, Ryan Bigg  wrote:
> The code for the forums controller looks suspiciously like Beast's.  
> Perhaps a little bit of attribution credit wouldn't go astray?
> -
> Ryan Bigg
> Freelancerhttp://frozenplague.net
>
> On 31/12/2008, at 1:34 PM, knewter wrote:
>
>
>
> > Hello everyone,
>
> > I just wanted to introduce Ansuz (a rails-based Content Management
> > System, sort of aiming for the wordpress-y space for the rails jet
> > set).  It's BSD licensed, and you can find it athttp://www.ansuzcms.com
> > orhttp://github.com/knewter/ansuz/tree/master.  There was an article
> > in the 2008 Advent Calendar about it, and Akita mentioned it once in
> > his blog, but other than that I don't believe it's received any
> > visibility whatsoever.
>
> > It does have extensive plugin support using engines, theming
> > capabilities thanks to theme_support (as well as a way to install
> > themes from the master theme repository at ansuzcms.com from within
> > the admin interface).  It also has a crowdsound widget in the admin,
> > so anyone using it ever can just easily report issues or feature
> > suggestions.  We've got a lighthouse if you find a bug, also linked
> > from within the admin interface.  I'm constantly sitting in #ansuz on
> > FreeNode, as well as some other users and developers, available for
> > support / to compliment your haircut.  I'll talk you through
> > installing it, whatev.
>
> > It's been successfully run in a host of environments, my ubuntu/mysql
> > to Lex's AIX/DB2, on the mac, and I think windows (shudder).  It
> > currently hosts the ansuzcms.com site as well as my company's site at
> >http://www.isotope11.com.  If anyone ever wants to talk about it or
> > learn how parts of it work, or be walked through it step by step, or
> > whatever...we're here :)  It's got a decent number of plugins as well.
>
> > Anyway, hoping some people will join in the development.  Have a happy
> > new year's.
>
> > Josh Adams
> > isotope11
> >http://www.isotope11.com
>
> > PS - at first I sent this to the really old rails mailing list that's
> > been dead for two years-ish.  Oops.
--~--~-~--~~~---~--~~
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: Ansuz CMS

2008-12-30 Thread Ryan Bigg

The code for the forums controller looks suspiciously like Beast's.  
Perhaps a little bit of attribution credit wouldn't go astray?
-
Ryan Bigg
Freelancer
http://frozenplague.net







On 31/12/2008, at 1:34 PM, knewter wrote:

>
> Hello everyone,
>
> I just wanted to introduce Ansuz (a rails-based Content Management
> System, sort of aiming for the wordpress-y space for the rails jet
> set).  It's BSD licensed, and you can find it at http://www.ansuzcms.com
> or http://github.com/knewter/ansuz/tree/master.  There was an article
> in the 2008 Advent Calendar about it, and Akita mentioned it once in
> his blog, but other than that I don't believe it's received any
> visibility whatsoever.
>
> It does have extensive plugin support using engines, theming
> capabilities thanks to theme_support (as well as a way to install
> themes from the master theme repository at ansuzcms.com from within
> the admin interface).  It also has a crowdsound widget in the admin,
> so anyone using it ever can just easily report issues or feature
> suggestions.  We've got a lighthouse if you find a bug, also linked
> from within the admin interface.  I'm constantly sitting in #ansuz on
> FreeNode, as well as some other users and developers, available for
> support / to compliment your haircut.  I'll talk you through
> installing it, whatev.
>
> It's been successfully run in a host of environments, my ubuntu/mysql
> to Lex's AIX/DB2, on the mac, and I think windows (shudder).  It
> currently hosts the ansuzcms.com site as well as my company's site at
> http://www.isotope11.com.  If anyone ever wants to talk about it or
> learn how parts of it work, or be walked through it step by step, or
> whatever...we're here :)  It's got a decent number of plugins as well.
>
> Anyway, hoping some people will join in the development.  Have a happy
> new year's.
>
> Josh Adams
> isotope11
> http://www.isotope11.com
>
> PS - at first I sent this to the really old rails mailing list that's
> been dead for two years-ish.  Oops.
> >


--~--~-~--~~~---~--~~
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: Redirecting The Root Of The Website

2008-12-30 Thread Near Cruise

Mike Mcc wrote:
> Digital Pardoe wrote:
>> 
>> It still doesn't physically redirect the user so they see 
>> http://website.com/home in their address bar.
>> 
>> I have however given you the benefit of the doubt and tried it, it 
>> didn't work.
> 
> It makes sense that you don't want two URIs on your site to have 
> identical content.
> 
> Here is a somewhat kludgy way to do this - in routes.rb:
> 
>   map.root :controller => 'home', :action => 'redirect'
> 
> Then in the home_controller.rb:
> 
>   def redirect
> redirect_to url_for(:controller => 'home', :action => 'index')
>   end

Hi:

1.in Configure/routes.rb

add a command:  map.root :controller => "home"

2.delete public/index.html . Or it will not happen.

Cruise
-- 
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] Ansuz CMS

2008-12-30 Thread knewter

Hello everyone,

I just wanted to introduce Ansuz (a rails-based Content Management
System, sort of aiming for the wordpress-y space for the rails jet
set).  It's BSD licensed, and you can find it at http://www.ansuzcms.com
or http://github.com/knewter/ansuz/tree/master.  There was an article
in the 2008 Advent Calendar about it, and Akita mentioned it once in
his blog, but other than that I don't believe it's received any
visibility whatsoever.

It does have extensive plugin support using engines, theming
capabilities thanks to theme_support (as well as a way to install
themes from the master theme repository at ansuzcms.com from within
the admin interface).  It also has a crowdsound widget in the admin,
so anyone using it ever can just easily report issues or feature
suggestions.  We've got a lighthouse if you find a bug, also linked
from within the admin interface.  I'm constantly sitting in #ansuz on
FreeNode, as well as some other users and developers, available for
support / to compliment your haircut.  I'll talk you through
installing it, whatev.

It's been successfully run in a host of environments, my ubuntu/mysql
to Lex's AIX/DB2, on the mac, and I think windows (shudder).  It
currently hosts the ansuzcms.com site as well as my company's site at
http://www.isotope11.com.  If anyone ever wants to talk about it or
learn how parts of it work, or be walked through it step by step, or
whatever...we're here :)  It's got a decent number of plugins as well.

Anyway, hoping some people will join in the development.  Have a happy
new year's.

Josh Adams
isotope11
http://www.isotope11.com

PS - at first I sent this to the really old rails mailing list that's
been dead for two years-ish.  Oops.
--~--~-~--~~~---~--~~
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] Use of #h method in a controller

2008-12-30 Thread Patrick Doyle
I have rails-2.2.2 installed on 2 different computers and routinely switch
back and forth between the two of them.  I just wrote some code today on my
desktop in which I invoked the #h method inside a controller (because I
wanted to sanitize a string prior to saving it in an instance variable).
When I got home this evening and pulled the code onto my laptop, I found
that I got an undefined method error for h.

Why would it be undefined on one computer but not the other?  The only thing
that I can think of is that I (most likely) have different sets of gems
installed (although both have rails 2.2.2 installed)

Any ideas?

--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: How to set homepage in Rails

2008-12-30 Thread Near Cruise

Hi:

Thank you very much.
Happy new year.

Cruise

Billy Hsu wrote:
> Hi:
> in config/routes.rb
> 
> map.root :controller => "share"
> 
> Happy new Year!
> 
> On Wed, Dec 31, 2008 at 10:34 AM, Near Cruise <
> rails-mailing-l...@andreas-s.net> wrote:
> 
>> --
>> Posted via http://www.ruby-forum.com/.
>>
>> >
>>
> 
> 
> --
> TWRUG Blog:
> http://blog.rubyonrails.org.tw
> 
> CFC on Rails:
> http://zusocfc.blogspot.com
> 
> Only two surfaces of a box:
> http://blog.pixnet.net/zusocfc

-- 
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] link_to_remote can't replace specified element?

2008-12-30 Thread JHuizingh

I'm having an issue with the design of my views that I can't seem to
wrap my head around.  I have a page where I am showing a collection of
objects in a list.  The way that I designed it, it looked something
like this:

main view:

here is the list

<%= render(:partial => "items/item", :collection => @items %>



collection item's view:

 
 ...  INFO ABOUT item



This works great, creating a  that is full of 's.  I hit a
snag when I start trying to update individual  items with ajax
calls.  The :update option for  link_to_remote() and related functions
doesn't give me an option to replace the dom element that it refers to
as far as I can tell.  It lets me specify a dom id that I can change
the innerHTML of, insert the returned html with in it at the beginning
or the end, before or after the element, but it doesn't seem to allow
me to REPLACE the element.

So a call like this:

remote_function(:url => credential_search_instance_path
(credential_search_instance),
 :method => :put,
 :update => dom_id(item)
   )

Will replace the html inside of the  element, so it would update
the page to look like this:

 
 
 ...  INFO ABOUT item




I ended up getting around the issue by checking if it is an xhr
request in my item view like this;
<% if ! request.xhr? then %>
 
<% end %>
 ...  INFO ABOUT item
<% if ! request.xhr? then %>

<% end %>

That solution works, but it seems very inelegant and adds a lot of
noise to the view.  Is it really true that I can't replace the dom
element?  Am I missing something?  Is there a better way to design my
view and partial?

Thanks,
Jonathan
--~--~-~--~~~---~--~~
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 set homepage in Rails

2008-12-30 Thread CFC
Hi:
in config/routes.rb

map.root :controller => "share"

Happy new Year!

On Wed, Dec 31, 2008 at 10:34 AM, Near Cruise <
rails-mailing-l...@andreas-s.net> wrote:

>
> Hi :
>
> If I want http://localhost:3000/share to be homepage
> http://localhost:3000/,
> How can I do setting from rails ,please?
>
> Thanks.
>
> Cruise
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>


-- 
TWRUG Blog:
http://blog.rubyonrails.org.tw

CFC on Rails:
http://zusocfc.blogspot.com

Only two surfaces of a box:
http://blog.pixnet.net/zusocfc

--~--~-~--~~~---~--~~
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: Forms fields pre-populating w/ first record's values

2008-12-30 Thread Ryan Bigg

form_tag does not tag a string as an argument.

Could you show us your controller please?

Also, it may help you if you read 
http://guides.rubyonrails.org/getting_started_with_rails.html 
  first.
-
Ryan Bigg
Freelancer
http://frozenplague.net







On 31/12/2008, at 12:30 PM, Clem Rock wrote:

>
> I have a strange situation.I want to have a create_user form w/  
> all
> the fields blank
>
> When I call the create_user method, the corresponding
> create_user.html.erb form is displaying the first
> record's data from the user table in the form fields
>
> Here's a quick view of my form:
>
> [code]
> <% form_tag('create_user') do -%>
>   <%=hidden_field("user", "id") %> (<%=params[:id] %>)
>   First Name
><%=text_field("user", "fname") %>
>
>   Last Name
><%=text_field("user", "lname") %>
>  <%=submit_tag("Create") %>
> <% end -%>
>
> [/code]
>
> When that form loads, it is populated w/ the First and last name from
> the first user record in the db.
>
> Anyway around this - I've tried everything I can think of.
>
> Thanks,
> Clem
> -- 
> 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] How to set homepage in Rails

2008-12-30 Thread Near Cruise

Hi :

If I want http://localhost:3000/share to be homepage
http://localhost:3000/,
How can I do setting from rails ,please?

Thanks.

Cruise
-- 
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: A question about ajax

2008-12-30 Thread Zhao Yi

Vishwanath Nayak wrote:
> Hi,
> 
> First of all, if you want to use puts in your views, use <% %> tags 
> rather
> than <%= %> tags.
> Secondly, if you load your partials once you have your data 
> object(@project)
> with appropriate value your page should display the same.
> But if you change the value of @project.version after the partial is 
> loaded,
> it would not be reflected on the page until you reload the particular 
> div
> which has the text field tag with the partial.
> 
> -NAYAK
> 
> On Tue, Dec 30, 2008 at 6:42 PM, Zhao Yi

Hi,

This is my controller code:

def update_project_selection

   @project = Project.find(:all,:conditions=>"name='#{selected_project}' 
")
   render :partial => "project_version", :layout=>false
end

I update the @project object before load the partial. Why does the page 
display the same value?

Below is the view page:

<%=
select_tag:project_selection,options_for_select(@project_names)
%>

<%=
  observe_field :project_selection,
:frequency => 0.5,
:update => 'ajaxWrapper',
:url => {:action => 'update_project_selection'},
:with => "'project_selection='+encodeURIComponent(value)"
%>
-- 
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: AJAX replace items on a page progressively one at a time

2008-12-30 Thread JHuizingh

Thanks for your thoughts.  It got me on the right path.  I ended up
with a solution that had a small amount of frontend javascript code to
manage the ajax calls.  I used remote_function to create functions out
of the ajax call and put them in an array so I could call them
whenever I wanted.  It looked something like this.

on th page:

var calls_to_be_made = [];

in the view:

<% subtasks.each do |subtask| %>
  
... content here
  
  calls_to_be_made[calls_to_be_made.length] = function(){ <%=
remote_function(:update => dom_id(subtask), etc...) };

<% end %>


With this method I was able to start as many subtasks as I wanted like
this:

calls_to_be_made[0]();
calls_to_be_made[1]();

and then when one call returned I could have it kick of the next one
until there are none left.

Thanks!
Jonathan


On Dec 26, 4:16 pm, Frederick Cheung 
wrote:
> On 26 Dec 2008, at 21:56, JHuizingh wrote:
>
>
>
> > Is there a way that I can use the AJAX functionality built into rails
> > to make this happen without having to do some sort of custom control
> > mechanism to track all of the SubTasks on the client side?  Or is
> > there a better strategy to go about this?
>
> if the ajax update just re-rendered the list of subtasks then that  
> would probably be enough.
> Or if you want to use something fancier then you might have something  
> like
>
> def progress
>    #find the subtask that completed and assign it to @subtask
>    render :update do |page|
>      page[dom_id(@subtask)].addClassName('complete')
>    end
> end
>
> which will add the complete class to the div/span/whatever with the  
> appropriate id. You could then style it so that such items had a green  
> background or a check mark or whatever visual cue you want to give.
>
> 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] Forms fields pre-populating w/ first record's values

2008-12-30 Thread Clem Rock

I have a strange situation.I want to have a create_user form w/ all
the fields blank

When I call the create_user method, the corresponding
create_user.html.erb form is displaying the first
record's data from the user table in the form fields

Here's a quick view of my form:

[code]
<% form_tag('create_user') do -%>
   <%=hidden_field("user", "id") %> (<%=params[:id] %>)
   First Name
<%=text_field("user", "fname") %>

   Last Name
<%=text_field("user", "lname") %>
  <%=submit_tag("Create") %>
<% end -%>

[/code]

When that form loads, it is populated w/ the First and last name from
the first user record in the db.

Anyway around this - I've tried everything I can think of.

Thanks,
Clem
-- 
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] Rails 1.X to 2.1 routing problem

2008-12-30 Thread Jeff Pritchard

Hi,
I'm trying to bring an "old" rails app up to 2.1.

I'm getting this error when trying to access the app via an iFrame setup
we had working before for showing widgets on other domains pages:
ActionController::RoutingError (No route matches "/topics;summary" with
{:method=>:get}):

/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/routing/recognition_optimisation.rb:67:in
`recognize_path'

/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/routing/route_set.rb:385:in
`recognize'

/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/dispatcher.rb:148:in
`handle_request'
yadda yadda...


My routes.rb has this:
  map.resources :topics,
{ :member => { :rank_item => :put,
   :rank_items => :put,
   :widgets => :get },
  :collection => { :summary => :get },
  :new => { :copy => :post,
:link => :post } }


and my topics controller has a "summary" method.

Any ideas what has changed that makes this no longer valid?  The other
developer on the job set this part up, and I never quite understood it.
Seems to be a pre-cursor to the "modern" REST way of doing things, but
seems only to complicate something that would otherwise be simple.

Anyway, enough bitching from me.  Anyone know what's wrong here?

many thanks,
jp
-- 
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: problems w/ partials and yield

2008-12-30 Thread Clem Rock

What I'm trying to accomplish is this.  I have a simple layout called 
main.erb.html with a catch all <%=yield %> for content.

I keep running into the situation where so many actions' partials are so 
similar it seems ridiculous to keep re-creating one for every action. 
I would like to do something like this:

I have these actions:

create_users,
update_users
update_user_password

Instead of creating 3 partials, it would be nice to use 1 partial and 
just show certain fields like this:

%=if controller.action_name == 'create_users' %>
  Show these fields
<% end -%>

%=if controller.action_name == 'update password' %>
  Show these fields
<% end -%>

ect.




Robby Russell wrote:
> Are you familiar with content_for ?
> 
> <%= yield :list_roles -%>
> 
> <% content_for :list_roles, 'content here' -%>
> 
> or as a block
> 
> <% content_for :list_roles do %>
>   content here...
> <% end %>
> 
> Cheers,
> Robby
> 
> On Fri, Dec 26, 2008 at 12:15 PM, Clem Rock
>  wrote:
>> If I try to use render :partial => 'list_roles' in the create method,
>> --
>> Posted via http://www.ruby-forum.com/.
>>
>> >
>>
> 
> 
> 
> --
> Robby Russell
> Chief Evangelist, Partner
> 
> PLANET ARGON, LLC
> design // development // hosting w/Ruby on Rails
> 
> http://www.planetargon.com/
> http://www.robbyonrails.com/
> aim: planetargon
> 
> +1 503 445 2457
> +1 877 55 ARGON [toll free]
> +1 815 642 4068 [fax]

-- 
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: Finding Child Records Efficiently

2008-12-30 Thread Mark Reginald James

Mark Reginald James wrote:

> os = sanitize("/#{old_name}/")
> ns = sanitize("/#{new_name}/")

Whoops, you'd need to add the prefix /path/to on these
to ensure you only replace the name in the correct context.

> Person.update_all "key = replace(key, #{os}, #{ns})",
>   ['key like ?', "/path/to/#{old_name}/%"]

-- 
Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.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: when to set a class attribute variable during boot

2008-12-30 Thread Mark Reginald James

Daniel Choi wrote:
> I have an ActiveRecord model with a cattr_accessor. The class
> attribute is set up like this:
> 
> class MyModel < ActiveRecord::Base
>   cattr_accessor :my_attribute
> end
> 
> Because I need to give #my_attribute environment-specific values, I
> try to set this attribute in environments/development.rb like so:
> 
> MyModel.my_attribute = 3
> 
> But this leads to odd and erratic behavior when #my_attribute is
> called from a controller. Sometimes MyModel.my_attribute returns 3,
> but sometimes it returns nil.

In development mode, models get reloaded on every request,
so your variable won't persist. You'll have to set it in
in a persistent class or module, in the global context,
or in the database or session.

-- 
Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.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: Finding Child Records Efficiently

2008-12-30 Thread Mark Reginald James

DAZ wrote:

> I guess that keeping the ancestors as a string in the database makes
> more sense than I first thought. It is interesting that Robert refers
> to this as 'caching' the family-tree, which obviously it is, but I've
> not really thought of caching information like this (ie database level
> relationships) before. Consequently, as Mark says it needs to be
> updated whenever a name changes, which shouldn't be too difficult to
> do (cycle through all the descendants and update that row?).

Yes, you could use a recursive (tree) or batch (nested-set) traverse.
Or could actually do it in one statement, like

os = sanitize("/#{old_name}/")
ns = sanitize("/#{new_name}/")
Person.update_all "key = replace(key, #{os}, #{ns})",
  ['key like ?', "/path/to/#{old_name}/%"]


> This has the added advantage of acting as a sort of permalink row as
> well. Thinking about pretty urls, it wouldn't be too hard to use this
> string to generate:
> 
> http://appname/people/abe/homer/bart
> 
> This would be the url that took you directly to Bart's url. Could I
> use the '/' character as a separator at the DB level?

Yes, good idea.

> Mark - I'm not sure what you mean by this:
>> you should put the name match into the
>> SQL conditions rather than in a Ruby loop.
> 
> I guess that you mean to use SQL rather than looping through ruby
> arrays, but I'm afraid my SQL is very poor - I usually only use the
> Rails helpers to do basic stuff.  I'm struggling to follow your
> example, but I guess that it corresponds to what Philip was alluding
> to by saying to construct a joins string?

person.children.find(:conditions => ['name = ?', name])


-- 
Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.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] when to set a class attribute variable during boot

2008-12-30 Thread Daniel Choi

I have an ActiveRecord model with a cattr_accessor. The class
attribute is set up like this:

class MyModel < ActiveRecord::Base
  cattr_accessor :my_attribute
end

Because I need to give #my_attribute environment-specific values, I
try to set this attribute in environments/development.rb like so:

MyModel.my_attribute = 3

But this leads to odd and erratic behavior when #my_attribute is
called from a controller. Sometimes MyModel.my_attribute returns 3,
but sometimes it returns nil.

Any suggestions?
--~--~-~--~~~---~--~~
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: Layout with yield usage?

2008-12-30 Thread Eric

Use <%= yield :navigation %> in your layout instead of the
render :partial, and use content_for :navigation in your view(s).
Watch Railscast 8.

Also, have you checked to see whether your nav render is duplicated in
the view?

-eric

On Dec 30, 10:14 am, net  wrote:
> Hi!
>
> Im having this weird problem when the yield gets overwritten with the
> last yield used.. My application layout looks like this:
>
>         
>             <%= render :partial => "shared/navigation" %>
>         
>
>         
>             <%= yield %>
>         
>
> And the output becomes:
>
>         
>             ### NAVIGATION CONTENT ###
>         
>
>         
>             ### NAVIGATION CONTENT ###    <-- i want this to be ###
> MAIN CONTENT ###
>         
>
> Am I using layouts/partials incorrectly?
--~--~-~--~~~---~--~~
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: Problem with associations that could be null sometimes

2008-12-30 Thread Ivor Paul
Yes, you can :)

On Tue, Dec 30, 2008 at 4:49 AM, cassiozen  wrote:

>
> Hi Everybody,
>
> I'm developing a little task management system with a Task model that
> belongs to Users and Projects.
>
> The problem is that sometimes a task won't belongs to an user AND a
> project. It will be possible to add a task to a project without
> delegate it to any user. In a similar way, it will be possible for
> users to create a new task without assigning it to any project.
>
> So, my question is: Can I simply create the belongs_to associations
> for the Task model and leave the foreign_ids empty in the cases where
> the task doesn't have an user or a project? Is there a better
> solution?
>
> 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: Arguments Error

2008-12-30 Thread Ryan Ororie

Freddy Andersen wrote:
> Where does the cart_item come from? is that in the Store controller?
> post the store controller... The view has the @cart object but also
> needs the cart_item.. Is that from the session?

cart_item.rb is the name of a model file, the one that starts with class 
CartItem from above.

My store_controller.rb looks like this:

class StoreController < ApplicationController

  def index
@products = Product.find_products_for_sale
  end

  def add_to_cart
@cart = find_cart
product = Product.find(params[:id])
@cart.add_product(product)
  end

  private
  def find_cart
session[:cart] ||=Cart.new
  end
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: Arguments Error

2008-12-30 Thread Freddy Andersen

Where does the cart_item come from? is that in the Store controller?
post the store controller... The view has the @cart object but also
needs the cart_item.. Is that from the session?
--~--~-~--~~~---~--~~
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] gems:unpack dosn't deploy hpricot

2008-12-30 Thread Mikael Rudberg

Hi

I'm trying to unpack hpricot to my vendor/gems direcotry.

i have config.gem "hpricot" in my environment.rb file

but when i run "rake gems:unpack" it dosn't do anything. Is there any
special mesures thats needs to be done.

I running Vista with rails 2.2.2 and have hpricot gem (0.6.164).

I've successfully unpacked several other gems with this method.

Any suggestions would be very welcome

Thanks

/Mikael
-- 
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] Layout with yield usage?

2008-12-30 Thread net

Hi!

Im having this weird problem when the yield gets overwritten with the
last yield used.. My application layout looks like this:


<%= render :partial => "shared/navigation" %>



<%= yield %>


And the output becomes:


### NAVIGATION CONTENT ###



### NAVIGATION CONTENT ###<-- i want this to be ###
MAIN CONTENT ###


Am I using layouts/partials incorrectly?

--~--~-~--~~~---~--~~
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: Best Modal Popup for Rails

2008-12-30 Thread kwangsub

hi David
I have same problem.

private method `copy' called for File:Class

at first.

as you said, some of tue function are not updated.
so, how can i solve this problem?

thanks.


On 11월22일, 오전10시25분, David  wrote:
> It looks like this is the problem, some of the functions are not
> updated for newer versions of prototype(from the posts on craigs
> site), but I tried this and this still does not work:
>
> Redbox is broken.
>
> These lines are indeed wrong:
> Element.setTop(window_id, boxTop);
> Element.setLeft(window_id, boxLeft);
>
> It looks like Graig wanted to use the lightbox functions.
>
> To repair replace those lines with:
> $(window_id).style.top = boxTop +"px";
> $(window_id).style.left = boxLeft +"px";
>
> On Nov 21, 5:04 pm, David  wrote:
>
> > Hey, I am trying to get RedBox working but have run into some issues.
> > When I click on a Redbox link, everything works except that a white
> > blank div element appears at the top of the screen in the middle no
> > matter what.  I thought it may be an issue with the installation b/c I
> > noticed that the plugin install did not copy the appropriate files to
> > the right folders.  So I tried updating but got this error(I installed
> > all the files manually):
>
> > rake aborted!
> > private method `copy' called for File:Class
> > /Users/dlynam/rails_apps/clean/vendor/plugins/redbox/rakefile:28
>
> > Then I tried re-installing the plugin but I get an error with that
> > too.  It seems other people are getting the same errors as per the
> > posts on the Redbox page:
>
> > Plugin not found: ["svn://rubyforge.org/var/svn/ambroseplugins/
> > redbox"]
>
> > On Nov 20, 8:25 pm, "Bill Walton"  wrote:
>
> > > David wrote:
> > > > Thanks for the insight.  Does redbox play well with IE6?
>
> > > I have the luxery of only having to support FF.  The code does recognize 
> > > (at
> > > least some) browser-specific quirks, but I haven't tested it at all on IE.
> > > Sorry I can't be of more help.
>
> > > Best regards,
> > > Bill
>
>

--~--~-~--~~~---~--~~
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: link_to not asking confirmation (js)

2008-12-30 Thread Frederick Cheung



On Dec 30, 8:59 pm, Pablo Fernandez 
wrote:
> Hi, I have this link_to helper
>
> <%= link_to "edit", :action => 'edit', :id => @pirate, :confirm =>
> 'should edit?' %>
>
> It should (in order to what I read in apidock) prompt me for
> confirmation via javascript confirm, but it doesn't.
>
If you check the html generated you'll noticed that the url has a
confirm parameter. If you check apidoc again you'll see that the
confirm option needs to be passed in the second options hash, ie
link_to 'blah', {options for url}, {other stuff here}
> Any idea why?
>
> Also when I set the :id attribute, either @pirate or @pirate.id
> work... why is that, and what's the preferred form?
>
Because if you pass an activerecord object as the :id for a url rails
calls to_param on it, which by default returns id. The preferred form
these days would be to have the appropriate routes and do link_to
'edit', edit_pirate_path(@pirate)

Fred
> 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: Arguments Error

2008-12-30 Thread Ryan Ororie

> a Sorry I see now I was thinking that the CartItem class was an
> activerecord class ... The issue is this:
> Here you call a new object of CartItem with a product passed
> @items << CartItem.new(product)
> But here in the initialize you do not have a argument for
> initialize...
> class CartItem
>   attr_reader :product, :quantity
>   def initialize
> @product = product
> @quantity = 1
>   end
> Change it to this
> class CartItem
>   attr_reader :product, :quantity
>   def initialize( product )
> @product = product
> @quantity = 1
>   end

Interesting, tried that and it's spitting a "no method for cart_item 
back at me:

 NameError in Store#add_to_cart

Showing app/views/store/add_to_cart.rhtml where line #4 raised:

undefined local variable or method `cart_item' for 
#<#:0x26028e8>

Extracted source (around line #4):

1: The shopping cart
2: 
3:   <% for item in @cart.items %>
4: <%= cart_item.quantity %> × <%= h(item.title) %>
5:   <% end %>
6: 

RAILS_ROOT: script/../config/..
Application Trace | Framework Trace | Full Trace

#{RAILS_ROOT}/app/views/store/add_to_cart.rhtml:4:in 
`_run_rhtml_47app47views47store47add_to_cart46rhtml'
#{RAILS_ROOT}/app/views/store/add_to_cart.rhtml:3:in `each'
#{RAILS_ROOT}/app/views/store/add_to_cart.rhtml:3:in 
`_run_rhtml_47app47views47store47add_to_cart46rhtml'


Any idea?
-- 
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: Arguments Error

2008-12-30 Thread Freddy Andersen

Looks like you have two open posts for the same issue... Here is the
answer from the other post...

a Sorry I see now I was thinking that the CartItem class was an
activerecord class ... The issue is this:
Here you call a new object of CartItem with a product passed
@items << CartItem.new(product)
But here in the initialize you do not have a argument for
initialize...
class CartItem
  attr_reader :product, :quantity
  def initialize
@product = product
@quantity = 1
  end
Change it to this
class CartItem
  attr_reader :product, :quantity
  def initialize( product )
@product = product
@quantity = 1
  end

I would NEVER store the cartitem(add product to cart) in a session
object for a ecommerce application. Yes there are things that could/
should be stored in the session but not something like adding a
product to your cart... Unless you have a session replication system
for your back-end which then would store the session in either the
database or memcache anywho...

--~--~-~--~~~---~--~~
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: Arguments Error

2008-12-30 Thread Ryan Ororie


> Probably.
> 
> You could always add a parameter to your CartItem#initialize method. 
> I'm
> not sure that you're heading in the direction you want to be heading, 
> since
> it appears that CartItem is not derived from ActiveRecord::Base -- it's 
> not
> tied to a database.
> 
> You might want to go back and study Rail's ideas regarding models, how 
> they
> tie to database tables, and how you can initialize them.

I following along from the book DHH wrote verbatim, but it's the second 
edition. It was my understanding that having a database table for the 
cart was unnecessary because it's session data and would be avaliable 
based on that user?



-- 
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: Arguments Error

2008-12-30 Thread Patrick Doyle
>
> > CartItem#initialze
> > -- expects 0 arguments, you passed 1 argument in via CartItem#new
>
>
> I'm not really sure what do do with that -- what should I change? Are
> you saying only my CartItem#initialze is wrong?
>
Probably.

You could always add a parameter to your CartItem#initialize method.  I'm
not sure that you're heading in the direction you want to be heading, since
it appears that CartItem is not derived from ActiveRecord::Base -- it's not
tied to a database.

You might want to go back and study Rail's ideas regarding models, how they
tie to database tables, and how you can initialize them.

--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] link_to not asking confirmation (js)

2008-12-30 Thread Pablo Fernandez

Hi, I have this link_to helper

<%= link_to "edit", :action => 'edit', :id => @pirate, :confirm =>
'should edit?' %>

It should (in order to what I read in apidock) prompt me for
confirmation via javascript confirm, but it doesn't.

Any idea why?

Also when I set the :id attribute, either @pirate or @pirate.id
work... why is that, and what's the preferred form?

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: Arguments Error

2008-12-30 Thread Ryan Ororie


> StoreController#add_to_cart
> -- doesn't expect any methods, but this is called by the Rails framework 
> as
> an action, and Rails doesn't pass any arguments to the action methods

> Cart#add_product
> -- expects 1 argument, you're calling it with 1 argument in
> StoreController#add_to_cart

> CartItem#new
> -- calls CartItem#initialize with however many arguments it was passed
> -- is called with 1 argument in Cart#add_product

> CartItem#initialze
> -- expects 0 arguments, you passed 1 argument in via CartItem#new


I'm not really sure what do do with that -- what should I change? Are 
you saying only my CartItem#initialze is wrong?
-- 
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: Wrong number of arguments?

2008-12-30 Thread Freddy Andersen

a Sorry I see now I was thinking that the CartItem class was an
activerecord class ... The issue is this:

Here you call a new object of CartItem with a product passed
@items << CartItem.new(product)

But here in the initialize you do not have a argument for
initialize...

class CartItem
  attr_reader :product, :quantity
  def initialize
@product = product
@quantity = 1
  end

Change it to this

class CartItem
  attr_reader :product, :quantity
  def initialize( product )
@product = product
@quantity = 1
  end
--~--~-~--~~~---~--~~
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: Arguments Error

2008-12-30 Thread Patrick Doyle
Your error message is:

wrong number of arguments (1 for 0)

That means that somewhere, you are calling a method that doesn't expect any
arguments and you are passing an argument to it.  The stack trace give you a
clue:

ArgumentError in StoreController#add_to_cart

app/models/cart.rb:13:in `initialize'
app/models/cart.rb:13:in `new'
app/models/cart.rb:13:in `add_product'
app/controllers/store_controller.rb:10:in `add_to_cart'
One of the methods listed (#add_to_cart, #initialize, #new, or #add_product)
is being called with an argument where it wasn't expecting one.

StoreController#add_to_cart
-- doesn't expect any methods, but this is called by the Rails framework as
an action, and Rails doesn't pass any arguments to the action methods
Cart#add_product
-- expects 1 argument, you're calling it with 1 argument in
StoreController#add_to_cart
CartItem#new
-- calls CartItem#initialize with however many arguments it was passed
-- is called with 1 argument in Cart#add_product
CartItem#initialze
-- expects 0 arguments, you passed 1 argument in via CartItem#new

--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: Arguments Error

2008-12-30 Thread Ryan Ororie

Also, my add_to_cart.rhtml view looks like this:

The shopping cart

  <% for item in @cart.items %>
<%= cart_item.quantity %> × <%= h(item.title) %>
  <% 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] Arguments Error

2008-12-30 Thread Ryan Ororie

I'm new to rails so I apologize for my ignorance in advance... I'm
working through a tutorial here but I think it may be written for a
slightly older version of rails. Trying to make a store app.

I'm getting the following error (with application trace shown):

ArgumentError in StoreController#add_to_cart

wrong number of arguments (1 for 0)

RAILS_ROOT: script/../config/..
Application Trace | Framework Trace | Full Trace

app/models/cart.rb:13:in `initialize'
app/models/cart.rb:13:in `new'
app/models/cart.rb:13:in `add_product'
app/controllers/store_controller.rb:10:in `add_to_cart'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:76:in
`process'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in
`synchronize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in
`process'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in
`process_client'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in
`process_client'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in
`initialize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in
`initialize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in
`run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in
`each'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in
`run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in
`run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281


Now I *think* this means that I have a problem with my
store_controller.rb file, which looks like this:

class StoreController < ApplicationController

  def index
@products = Product.find_products_for_sale
  end

  def add_to_cart
@cart = find_cart
product = Product.find(params[:id])
@cart.add_product(product)
  end

  private
  def find_cart
session[:cart] ||=Cart.new
  end
end

But, I'm not sure - and it does seem a bit strange that that would be
where the error originates from as I didn't change anything in this file
from when it was working to when I got the error.

What I did do was create a model called cart_item.rb:

class CartItem
  attr_reader :product, :quantity

  def initialize
@product = product
@quantity = 1
  end

  def increment_quantity
@quantity += 1
  end

  def title
@product.title
  end

  def price
@product.price * @quantity
  end
end

And edited the cart.rb model to include a more robust add_product, it
now looks like this:

class Cart
  attr_reader :items

  def initialize
@items = []
  end

  def add_product(product)
current_item = @items.find {|item| item.product == product}
if current_item
  current_item.increment_quantity
else
  @items << CartItem.new(product)
end
  end
end

I had it pointed out to me that the line;
current_item = @items.find {|item| item.product == product}

Should be;
current_item = @items.detect {|item| item.product == product}

But this didn't result in any change... would REALLY appreciate any
insight!
-- 
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: A question about ajax

2008-12-30 Thread Phlip

NAYAK wrote:

> First of all, if you want to use puts in your views, use <% %> tags 
> rather than <%= %> tags.

> I defines a partial see below:
> <%=
>  puts @project.version
>  text_field_tag "project_version", @project.version
> %>

The above will puts the @project.version to the STDOUT stream, then will return 
the text_field_tag into the <%= %> location.

This is a subtle hair to split (and 'p' is more useful than 'puts' there), but 
debugging out of the top of a <%= %>, while expressing its last line, is very 
common...

-- 
   Phlip


--~--~-~--~~~---~--~~
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: Code refactoring is the key

2008-12-30 Thread Phlip

vlain wrote:
> After six month of development and a first release we decide to
> refactor our application. Since it was my first Ruby/Rails application
> there are a lot of horrible things inside it.

Next time, use TDD and refactoring as you go. You would have shipped much 
sooner, with fewer bugs.

> And now? Some general hints?

If you do not have unit tests (or "functional" tests, which are really just 
unit 
tests with a suggestive name), then do this:

  - start a new Rails project
  - pick the most important single _tiny_ feature in the old app
  - use TDD and refactoring to implement it int the new app
  - use the old app as a cheat sheet, but refrain from copying code out
  - repeat with each feature until done.

You will have a much cleaner application, with an exemplary design.

> I start with 2 simple questions:
> 1 - Where I put some common methods? Inside application.rb
> (controller) is ugly...

Refactor low hanging fruit. If your common methods have redundant lines that 
only talk about models, move them to models. Eventually your common methods 
will 
DRY up as if by themselves. Find the easiest possible refactors first - never 
attempt the hard ones while a bunch of easy ones are in the way. Eventually the 
hard ones will take care of themselves.

> 2 - In order to make skinny controller I write a lot of class method
> inside the model, maybe too much? Is this a common practice?

Yes - your models should fill up with lots of tiny methods, all apparently 
useless.

-- 
   Phlip


--~--~-~--~~~---~--~~
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] opera web browser ActionController::InvalidAuthenticityToken

2008-12-30 Thread Slawek Tuleja

Hi!

Problem with Opera web browser and protect_from_forgery.
Under Opera I have exception:
ActionController::InvalidAuthenticityToken, under Firefox, Chrome, IE -
protect_from_forgery works fine.

I googled internet not finding recipe.
Please for help.

Slawek
-- 
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] IntegrationTest doesn't affect model

2008-12-30 Thread Fritz Anderson

At the end of this message, I have (trimmed) code for an
IntegrationTest, controller, and model.

The IntegrationTest posts to a URL that should destroy a model object
("Secondary"). The Secondary belongs_to a Principal. The Secondary is
not deleted, nor is it removed from the Principal's has_many secondaries
relationship. (See the FAILS comments in the IntegrationTest.)

The PeopleControllerTest functional test exercises the same action in
the same way, and in that, the destroy succeeds. Running the application
from a browser, for the same action, succeeds.

I'd like my integration test to test whether user actions have effect in
the model. I understood that was the purpose. What is the cause of this
problem, or how should I pursue it?

ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
Rails 1.2.6

-- F

# In IntegrationTest
def test_existing_login
   https!(true)

   person = Principal.find_by_loginid('t-9fritz')
   # (omitted) log the person in and verify success

   # There should be one secondary for this person. Delete it.
   assert_equal 1, person.secondaries.count
   n_secondaries = Secondary.count
   sec_id = person.secondaries.first.id
   post_via_redirect '/people/delete_secondary/' + sec_id.to_s
   # (omitted) verify the redirect is as expected

   assert_equal n_secondaries - 1, Secondary.count
   # ^ FAILS. Secondary.count is unchanged.
   assert_raises(ActiveRecord::RecordNotFound) { Person.find(sec_id) }
   # ^ FAILS: The record is still in the DB.
   assert_equal 0, person.secondaries.count
   # ^ FAILS: The secondaries list is unchanged.
end

# In PeopleController
def delete_secondary
   @person = Person.find(params[:id])
principal = @person.principal

flash[:notice] = "Deleted contact #...@person.full_name}"
@person.destroy
redirect_to :action => :show, :id => principal
end

# In person.rb
# people is the table; Principal and Secondary are single-table
inheritors.
class Principal < Person
   has_many :secondaries, :class_name => 'Secondary',
:dependent => :destroy
   validates_associated :secondaries, :allow_nil => true
   # ...
end

class Secondary < Person
   belongs_to  :principal
   # ...
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: Wrong number of arguments?

2008-12-30 Thread Ryan Ororie

It might also be helpful to see my store_controller.rb file:

class StoreController < ApplicationController

  def index
@products = Product.find_products_for_sale
  end

  def add_to_cart
@cart = find_cart
product = Product.find(params[:id])
@cart.add_product(product)
  end

  private
  def find_cart
session[:cart] ||=Cart.new
  end
end

If I am reading the trace right (which I don't know that I am) I think 
the problem is on the @cart.add_product(product) line?
-- 
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: Finding Child Records Efficiently

2008-12-30 Thread Mark Thomas

I forgot you wanted actual names instead of IDs, but the same
principle applies. You can serialize strings in the same fashion.
Also, in my previous post I said 'descendants', when really
'ancestors' is more appropriate.

-- Mark.
--~--~-~--~~~---~--~~
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: YUI widgets, and JSON datasource generated by rails.

2008-12-30 Thread Mark Thomas

> I wonder if someone has tried to populate a
> YUI Datasource
> with JSON generated by a rails controller? (So to dynamicly updating a
> table, with a model
> represented in JSON format).
>
> Thanks, Christophe

Perhaps YUI4Rails does this?
http://github.com/mghaught/yui4rails/tree/master#README

--~--~-~--~~~---~--~~
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: Code refactoring is the key

2008-12-30 Thread Andrew Bloom

You can break up common methods and place them in modules. Then simply
"include" the module in ApplicationController (or any other set or sub
set of controllers as needed).

On Dec 30, 10:39 am, vlain  wrote:
> After six month of development and a first release we decide to
> refactor our application. Since it was my first Ruby/Rails application
> there are a lot of horrible things inside it.
>
> And now? Some general hints?
>
> I start with 2 simple questions:
> 1 - Where I put some common methods? Inside application.rb
> (controller) is ugly...
> 2 - In order to make skinny controller I write a lot of class method
> inside the model, maybe too much? Is this a common practice?
--~--~-~--~~~---~--~~
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: Code refactoring is the key

2008-12-30 Thread Patrick Doyle
On Tue, Dec 30, 2008 at 11:39 AM, vlain  wrote:

>
> After six month of development and a first release we decide to
> refactor our application. Since it was my first Ruby/Rails application
> there are a lot of horrible things inside it.
>
> And now? Some general hints?
>
> I start with 2 simple questions:
> 1 - Where I put some common methods? Inside application.rb
> (controller) is ugly...
> 2 - In order to make skinny controller I write a lot of class method
> inside the model, maybe too much? Is this a common practice?
>

I'll chime in with the obvious
I would start by making sure that the application passes all of your tests.
If you have have not done this yet, be prepared for a lot of work.  Then be
prepared for more work as you write tests to cover everything you've
written.

--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] problem logging out from RESTful authentication

2008-12-30 Thread Patrick Doyle
I just plugged RESTful authentication into my application (following the
outline given in Ryan Bate's railscast).  As I was doing so, I was reading
through the code.  (I know, what a concept! :-)) I noticed that the
AuthenticatedSystem#access_denied method redirects to
#request_http_basic_authentication for anything other than .html requests.
Being a naturally curious kind of fellow, I logged out of my application and
plugged in http://localhost:3000/documents.xml to see what would happen.
Sure enough, the standard web login/password screen popped up on my browser
(Firefox 3.0.5).  After providing my username and password, I got to see an
XML representation of my data.  So then I when I went back to
http://localhost:3000/documents, I was able to see the documents in my
database, having used HTTP authentication to log in.

Well, that was kinda cool... I guess.

Then I tried to log out.

And I tried again.

I could no longer log out of my application.  Nothing I tried worked.  I
tried shutting down and restarting the server (Mongrel).  I tried changing
the session secret key (restarting the server).  I tried deleting the cookie
from Firefox.  I tried deleting all cookies from Firefox.

Finally, I exited Firefox, restarted the server, restarted Firefox, and got
back to my "not logged in" screen.

Just in case there are other "naturally curious kinds of people" out there,
with more time on their hands than is really good for them, I thought I
would write this down, send it out, and see what folks say.

What do folks say?

--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] Code refactoring is the key

2008-12-30 Thread vlain

After six month of development and a first release we decide to
refactor our application. Since it was my first Ruby/Rails application
there are a lot of horrible things inside it.

And now? Some general hints?

I start with 2 simple questions:
1 - Where I put some common methods? Inside application.rb
(controller) is ugly...
2 - In order to make skinny controller I write a lot of class method
inside the model, maybe too much? Is this a common practice?
--~--~-~--~~~---~--~~
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: Preventing a form from submitting on ENTER

2008-12-30 Thread pepe

You can add Javascript to check for the value of the key pressed and
ignore it if it is the Enter key. I had to do the exact same thing for
the Backspace key not long ago, which was working as the Back icon in
some instances.

I have a sample but not here. I could give it to you if you still need
it tonight when I get home.

Pepe

On Dec 30, 5:16 am, Mukund  wrote:
> Create a form without a submit tag.   Put in another control on the
> web page that does $('id_of_my_form').submit(); using a javascript
> onclick event or whatever.
>
> Regards,
> Mukund
>
> sa 125 wrote:
> > Hi - I have the following problem: my app has a form that acts as a
> > filter to a table on the page, so that the user can search any value in
> > the table (via text box) or use select lists for more specific search.
> > The form is being observed by an observe_form helper that runs every 1-2
> > seconds or so. It's all still in testing.
>
> > I noticed that when I hit return while in the textbox, the form posts
> > and redirects me to an action unknown page. I want to remove that
> > functionality so that hitting enter wont do anything -- any idea how to
> > do it?
>
> > Thanks
> > --
> > 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: Wrong number of arguments?

2008-12-30 Thread Ryan Ororie

Freddy Andersen wrote:
> def add_product(product)
> current_item = @items.find {|item| item.product == product}
> if current_item
>   current_item.increment_quantity
> else
>   @items << CartItem.new(product)
> end
>   end
> 
> Try changing this to
> 
>   def add_product(product)
> current_item = @items.find {|item| item.product == product}
> if current_item
>   current_item.increment_quantity
> else
>   item = CartItem.create(product)
>   @items << item
> end
>   end

This changed my error to:

undefined method `create' for CartItem:Class

Might be worth nothing that when I try to clear the session this is what 
I get:

bio4054059:depot rmorourk$ rake db:sessions:clear
(in /Users/rmorourk/Sites/depot)
/Users/rmorourk/Sites/depot/config/boot.rb:26:Warning: 
Gem::SourceIndex#search support for String patterns is deprecated
bio4054059:depot rmorourk$
-- 
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: A CSS issue

2008-12-30 Thread John Ivanoff

http://www.alistapart.com/articles/progressiveenhancementwithcss/

On Dec 29, 8:37 am, John Ivanoff  wrote:
> Box models
>
> here's a handy IE toolbar
> --
> Internet Explorer Developer 
> Toolbarhttp://www.microsoft.com/downloadS/details.aspx?familyid=E59C3964-672...
>
> I don't consider myself a guru.
> In looking at your CSS there could be a lot of cleaning up done.
> Example. you declare font-family in many places.
> You could make a "main.css" and  do
> --
> body {
>         font-family: Geneva, Arial, Helvetica, sans-serif;
>         font-size: medium;}
>
> --
>
> That way your fonts are the same and since you're declaring it once
> less to download.
> You could go further and make a "type_001.css" and just declare all
> your typography in it.
> When you want to change you font change the file to say "type_002.css"
> that way the cached css won't be pulled and you wonder why the type
> hasn't changed.
>
> You could do the same for:
> reset (http://meyerweb.com/eric/tools/css/reset/)
> layout (positioning)
> style (colors and other eye candy)
>
> my 2 cents
>
> John
>
> On Dec 29, 4:01 am, Fernando Perez 
> wrote:
>
> > MaD wrote:
> > > personallly i use
> > > transparent borders instead of padding/margin, when i encounter such a
> > > problem.
>
> > That's an excellent piece of advice, and it is what I also use, but it
> > doesn't work all the time if there is a special background. Another
> > problem are floating elements, try switching them from left to right and
> > switch the order they appear in the html, sometimes it will avoid IE
> > adding a double margin.
> > --
> > 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: Wrong number of arguments?

2008-12-30 Thread Freddy Andersen

  def add_product(product)
current_item = @items.find {|item| item.product == product}
if current_item
  current_item.increment_quantity
else
  @items << CartItem.new(product)
end
  end

Try changing this to

  def add_product(product)
current_item = @items.find {|item| item.product == product}
if current_item
  current_item.increment_quantity
else
  item = CartItem.create(product)
  @items << item
end
  end
--~--~-~--~~~---~--~~
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: Wrong number of arguments?

2008-12-30 Thread Ryan Ororie

MaD wrote:
> when you get the error mentioned above, there should be the rails
> trace right on the same page (the part where rails tells you in which
> line of your code and on which method the error occurred).

Here is the full trace:

app/models/cart.rb:13:in `initialize'
app/models/cart.rb:13:in `new'
app/models/cart.rb:13:in `add_product'
app/controllers/store_controller.rb:10:in `add_to_cart'
/Users/rmorourk/.gem/ruby/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in
 
`send'
/Users/rmorourk/.gem/ruby/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:1095:in
 
`perform_action_without_filters'
/Users/rmorourk/.gem/ruby/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:632:in
 
`call_filter'
/Users/rmorourk/.gem/ruby/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:619:in
 
`perform_action_without_benchmark'
/Users/rmorourk/.gem/ruby/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in
 
`perform_action_without_rescue'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293:in
 
`measure'
/Users/rmorourk/.gem/ruby/1.8/gems/actionpack-1.13.3/lib/action_controller/benchmarking.rb:66:in
 
`perform_action_without_rescue'
/Users/rmorourk/.gem/ruby/1.8/gems/actionpack-1.13.3/lib/action_controller/rescue.rb:83:in
 
`perform_action'
/Users/rmorourk/.gem/ruby/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in
 
`send'
/Users/rmorourk/.gem/ruby/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:430:in
 
`process_without_filters'
/Users/rmorourk/.gem/ruby/1.8/gems/actionpack-1.13.3/lib/action_controller/filters.rb:624:in
 
`process_without_session_management_support'
/Users/rmorourk/.gem/ruby/1.8/gems/actionpack-1.13.3/lib/action_controller/session_management.rb:114:in
 
`process'
/Users/rmorourk/.gem/ruby/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:330:in
 
`process'
/Users/rmorourk/.gem/ruby/1.8/gems/rails-1.2.3/lib/dispatcher.rb:41:in 
`dispatch'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:76:in 
`process'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in 
`synchronize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/rails.rb:74:in 
`process'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in 
`process_client'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in 
`process_client'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in 
`initialize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in 
`initialize'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:282:in 
`run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in 
`each'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:281:in 
`run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in 
`run'
/Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
/Users/rmorourk/.gem/ruby/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:488:in
 
`load'
/Users/rmorourk/.gem/ruby/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:488:in
 
`load'
/Users/rmorourk/.gem/ruby/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in
 
`new_constants_in'
/Users/rmorourk/.gem/ruby/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:488:in
 
`load'
/Users/rmorourk/.gem/ruby/1.8/gems/rails-1.2.3/lib/commands/servers/mongrel.rb:60
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in 
`gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Users/rmorourk/.gem/ruby/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in
 
`require'
/Users/rmorourk/.gem/ruby/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in
 
`new_constants_in'
/Users/rmorourk/.gem/ruby/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in
 
`require'
/Users/rmorourk/.gem/ruby/1.8/gems/rails-1.2.3/lib/commands/server.rb:39
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in 
`gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
script/server:3
-- 
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, sen

[Rails] Re: uploading csv

2008-12-30 Thread NAYAK
Hi,

You may want to upload the file initially through AJAX, parse it and display
the output for the user to validate.
If the user submits the same, you can upload the same parsed value rather
than re parsing the whole file all together.

-NAYAK

On Tue, Dec 30, 2008 at 6:26 PM, Rajkumar Surabhi <
rails-mailing-l...@andreas-s.net> wrote:

>
> hi all,
>  in my project i have to upload the csv file.i want to show the data of
> the file before submitting the form.
> how to do it..plesae help me its very urgent..
> --
> 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: A question about ajax

2008-12-30 Thread NAYAK
Hi,

First of all, if you want to use puts in your views, use <% %> tags rather
than <%= %> tags.
Secondly, if you load your partials once you have your data object(@project)
with appropriate value your page should display the same.
But if you change the value of @project.version after the partial is loaded,
it would not be reflected on the page until you reload the particular div
which has the text field tag with the partial.

-NAYAK

On Tue, Dec 30, 2008 at 6:42 PM, Zhao Yi
wrote:

>
> I defines a partial see below:
> <%=
>  puts @project.version
>  text_field_tag "project_version", @project.version
> %>
>
> I want the project version update-to-date. The first line can print the
> correct version value but the text field doesn't refresh to the new
> version.
> --
> 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: Problems installing mysql gem in Windows Vista

2008-12-30 Thread Mohammad Ali

I think the solution suggested by - CharlesB (25 Nov) is pretty
straight forward. Somehow the incomplete installation of mysql gem,
doesnt has the chance to add mysql's bin directory path to windows
environment variable "Path".
Simply put a an additional entry there, i.e. in my case "C:\wamp\bin
\mysql\mysql5.0.51b\bin" & vola! it works.

for someone like my colleague, (called me to help on the issue) who
doesnt knows how to do it,

right click the 'My Computer' (desktop icon) or  'Computer' ( in start
menu)
Choose 'Advance System Settings' from left panel
>From the 'System Properties' window select 'Advanced' tab,
click 'environment variables' button
locate 'Path' variable, usually in 'System Variables'
click 'Edit'
Add your Mysql's bin directory path to it i.e. ';C:\wamp\bin\mysql
\mysql5.0.51b\bin;"
click OK, OK

run the migration, it should work now.




copying & pasting the libmysql.dll file from mysql\bin directory to
ruby\bin is another workaround, reported by Ed from ruby-forum, but I
like the above solution, as it caters to the deficency left by
incomplete installation of gem install mysql.

On Dec 13, 4:31 am, TonyB  wrote:
> Hi Schalk
>
> I had the same problem with rails 2.2.2 ...
>
> ArgumentError (NULL pointer given):
>      (eval):3:in `each_hash'
>      (eval):3:in `all_hashes'
>
>  I my case I was running MySQL 5.1.30 on a Windows environment too so
> I decided to switch 'back' to MySQL 5.0.67 and this worked for me. So
> maybe this can help you or others solving the problem.
>
> On Nov 26, 12:39 am, Schalk Neethling 
> wrote:
>
> > Hey All,
>
> > Executing: gem install mysql --no-ri --no-rdoc tells me that it
> > installed one gem without any errors. However looking at the folder
> > inside InstantRails, something seems missing. There is no lib for example.
>
> > Also, a simple line like this:
>
> > @content = Content.find_by_permalink('introduction')
>
> > Is throwing one heck of an error (here is a small bit of it):
>
> > Processing ContentController#index (for 127.0.0.1 at 2008-11-26
> > 01:17:28) [GET]
> >     [4;36;1mSQL (1.0ms) [0m    [0;1mSET NAMES 'utf8' [0m
> >     [4;35;1mSQL (0.0ms) [0m    [0mSET SQL_AUTO_IS_NULL=0 [0m
> >     [4;36;1mContent Columns (33.0ms) [0m    [0;1mSHOW FIELDS FROM
> > `contents` [0m
> >     [4;35;1mContent Load (1.0ms) [0m    [0mSELECT * FROM `contents`
> > WHERE (`contents`.`permalink` = 'introduction') LIMIT 1 [0m
>
> > ArgumentError (NULLpointergiven):
> >      (eval):3:in `each_hash'
> >      (eval):3:in `all_hashes'
>
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:564:in
> > `select'
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in
> > `select_all_without_query_cache'
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:60:in
> > `select_all'
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:81:in
> > `cache_sql'
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:60:in
> > `select_all'
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:635:in
> > `find_by_sql'
>
> > No my first assumption is, this is related to a bad mysql gem
> > installation but, for the sake of covering all basis, does anyone know
> > whether anything has changed in the way databases get's set-up in the
> > database.yml file in 2.2.2?
>
> > Current:
>
> > development:
> >    adapter: mysql
> >    encoding: utf8
> >    database: osc_development
> >    username: user
> >    password: pass
> >    host: localhost
>
> > Thanks for all assistance, thankfully I now see that it is not only me
> > struggling with this issue.
> > Schalk
>
> > CharlesB wrote:
>
> > > I had the same exact error message when I first tried to install the
> > > mysql-2.7.3 gem. But from the error message, we clearly see that only
> > > the RDocs are not being installed.
>
> > > You can confirm that if you do a "gem list". If you want, you can
> > > simply do:
>
> > > gem install mysql --no-ri --no-rdoc
>
> > > It will install the gem, but not the documentation (which, from a
> > > Rails point of view, you should not be concerned about anyway).
>
> > > Other than that, if Rails 2.2.2 still fails to load, then either you
> > > have not installed MySQL server itself, or somehow libmysql.dll is not
> > > on the path list. Simply type "path" at the command prompt and check
> > > if your mysql\bin directory is listed there. If not, add it.
>
> > > Cheers!
>
> > > CharlesB

--~--~-~--~~~---~--~~
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

[Rails] YUI widgets, and JSON datasource generated by rails.

2008-12-30 Thread bouhie...@gmail.com

Hi there,

I am working on a module which will generate YUI widgets.

For now, I am using the YUI DataTable, which takes YUI Datasource as
source to
populate an html table. I wonder if someone has tried to populate a
YUI Datasource
with JSON generated by a rails controller? (So to dynamicly updating a
table, with a model
represented in JSON format).

Thanks, Christophe

--~--~-~--~~~---~--~~
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: rails/info/properties

2008-12-30 Thread Frederick Cheung


On 30 Dec 2008, at 14:36, Nike Mike wrote:
>
> how it is retrieving the information from  rails/info/properties
>
There is a magic controller inside rails itself which is only  
available if the development environment.

Fred
>
> 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: Who can consult with me on scaling and architecture?

2008-12-30 Thread shahroon ali
Could you tell me in detail that, what kind of applications you are
interested in?

Thanks & Regards,
Shahroon Ali Khan

On Tue, Dec 30, 2008 at 7:28 PM, Denis Haskin wrote:

>  If I were in your shoes (and had at least some money to spend, which it
> sounds like you do) I would get some consulting from
> http://www.engineyard.com/ and/or http://www.rightscale.com/, at the
> least.
>
> (Disclaimer: I have no affiliation with either company, and in fact have
> never done business with them.  Just know them by reputation.)
>
> dwh
>
>
> Robert Matei wrote:
>
> I'd love to pay someone who has serious scaling experience to talk with
> me about how to plan for scaling.
>
> I'm developing a network of applications in Rails that could see tens of
> millions of users. I'm in way over my head, so I'd like to talk to
> someone who's been through it before. I want to know:
> - how to architect applications to scale smoothly
> - how to manage the growth in hardware
> - whether it's a bad idea to go with Rails at all.
>
> I'm not really sure where to start looking though. Are there people or
> companies in the community who consult on these topics?
>
> And while we're on it, are there companies that offer part-time sysadmin
> services for Rails stacks?
>
>
>
> >
>

--~--~-~--~~~---~--~~
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/info/properties

2008-12-30 Thread Nike Mike

hi i had a doubt while creating a new rails project we are getting the
basic welcome message as


Welcome aboard
You’re riding Ruby on Rails!
About your application’s environment

on clicking the about ur applications we are getting the full
information about the gem version,rails path etc.I have checked the
index.html file.its calling prototype js with function

 function about() {
if (Element.empty('about-content')) {
  new Ajax.Updater('about-content', 'rails/info/properties', {
method: 'get',
onFailure:  function()
{Element.classNames('about-content').add('failure')},
onComplete: function() {new
Effect.BlindDown('about-content', {duration: 0.25})}
  });
} else {
  new Effect[Element.visible('about-content') ?
'BlindUp' : 'BlindDown']('about-content', {duration: 0.25});
}
  }

how it is retrieving the information from  rails/info/properties


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: Who can consult with me on scaling and architecture?

2008-12-30 Thread Denis Haskin
If I were in your shoes (and had at least some money to spend, which it 
sounds like you do) I would get some consulting from 
http://www.engineyard.com/ and/or http://www.rightscale.com/, at the least.

(Disclaimer: I have no affiliation with either company, and in fact have 
never done business with them.  Just know them by reputation.)

dwh


Robert Matei wrote:
> I'd love to pay someone who has serious scaling experience to talk with
> me about how to plan for scaling.
>
> I'm developing a network of applications in Rails that could see tens of
> millions of users. I'm in way over my head, so I'd like to talk to
> someone who's been through it before. I want to know:
> - how to architect applications to scale smoothly
> - how to manage the growth in hardware
> - whether it's a bad idea to go with Rails at all.
>
> I'm not really sure where to start looking though. Are there people or
> companies in the community who consult on these topics?
>
> And while we're on it, are there companies that offer part-time sysadmin
> services for Rails stacks?
>   

--~--~-~--~~~---~--~~
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: Finding Child Records Efficiently

2008-12-30 Thread Mark Thomas

In a tree-based model, you have some tradeoffs if you want to retrieve
multiple values efficiently. Usually this is an insert-time vs query-
time tradeoff. For example, if you wanted to keep track of the number
of descendants of any particular node, you would either have to
traverse the node's subtree to count all the children every time you
wanted that information, or whenever you insert a child, you add one
to the parent's descendant-count field, then the grandparent's, and so
on, eventually bubbling this information up to the root. This way
every node is guaranteed to have an up-to-date count.

Your situation is similar. You can add a descendants field containing
an array of descendant IDs. Using the built-in activerecord
serialization mechanism:

class Person < ActiveRecord::Base
  serialize :descendants
  ...
end

Every time you create a new Person, all you need to do is

  descendants = new_person.parent.descendants
  descendants << new_person.parent.id

Of course, this will be a bit more complex if you want to include
dependants from multiple parents, but the idea is the same. Now every
person includes a list of descendant IDs, and you'll need only a
single query.

-- Mark.
--~--~-~--~~~---~--~~
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: Rails requires RubyGems >= 1.1.1 : problem

2008-12-30 Thread alberto

$ gem install rubygems-update
$ update_rubygems

--~--~-~--~~~---~--~~
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: index => nil params jumbled *sometimes*

2008-12-30 Thread Matt Darby

Thanks for your help, it seems to have been having the hidden elements
outside a .
I wouldn't think that having hidden elements outside a cell (but still
in the form) would be invalid, but then again, I didn't explicitly
validate.

Thanks for your help ;)
--~--~-~--~~~---~--~~
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] A question about ajax

2008-12-30 Thread Zhao Yi

I defines a partial see below:
<%=
  puts @project.version
  text_field_tag "project_version", @project.version
%>

I want the project version update-to-date. The first line can print the
correct version value but the text field doesn't refresh to the new
version.
-- 
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] [ANN] Plugin: ColumnScope 1.0

2008-12-30 Thread Florian Aßmann

ColumnScope Plugin version 1.0 released!

* 

ColumnScope lets you select specified values from your DB into a model  
or an array without doing :select => SQL_FRAGMENT and map! {|r|r.foo}  
all the time.
This plugin extends ActiveRecord::Base and mixes in named scopes.  
ColumnScope is a subclass of ActiveRecord::NamedScope::Scope so it can  
be chained with named scopes.

Assume we have a Page(id:integer, path:string, title:string,  
body:text, timestamps) model and we have a page listing, there is no  
need to load the whole body for every page.
Maybe we need only the path and title:

   Page.selects(:path, :title).values.all(:order => 'id') # => [['/ 
foo', 'Foo'], ['/bar', 'Bar'], ...]

Further we can chain it with named scopes:

   Page.published.selects(:path, :title).values.all(:order => 'id') #  
=> [['/foo', 'Foo'], ['/baz', 'Baz'], ...]
   # or using a shortcut
   Page.published.select_all(:path__title, :order => 'id') # => [['/ 
foo', 'Foo'], ['/baz', 'Baz'], ...]

When this page is shown maybe we don't need the path and id anymore,  
but the instance of the model:

   Page.published.rejects(:id, :path).find params[:id] # => 

--
Cheers
Florian Aßmann


--~--~-~--~~~---~--~~
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] uploading csv

2008-12-30 Thread Rajkumar Surabhi

hi all,
 in my project i have to upload the csv file.i want to show the data of
the file before submitting the form.
how to do it..plesae help me its very urgent..
-- 
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] Problem with routes after upgrading to Rails 2.2.2

2008-12-30 Thread a...@s

Hello,
After I've upgraded my application to Rails 2.2.2 I get a Routing
Error:

#
 ActionController::RoutingError in Home#index

Showing app/views/application/_extjs_mainmenu.html.erb where line #19
raised:

currencies_purchases_url failed to generate from
{:controller=>"currencies_purchases", :action=>"index"} - you may have
ambiguous routes, or you may need to supply additional parameters for
this route.  content_url has the following required parameters:
["currencies_purchases", :format] - are they all satisfied?

Extracted source (around line #19):

16: new Ext.menu.Item({
17:   iconCls: 'x-menu-item-icon x-cols-icon',
18:   text: 'Currencies Purchases',
19:  href:'<%= currencies_purchases_path %>'
20: }),
21: new Ext.menu.Item({
22:   iconCls: 'x-menu-item-icon x-cols-icon',
###

Here is what I have in routes.rb:

###
 map.currencies_purchases 'currencies_purchases.:format' ,
:controller => 'currencies_purchases' ,
:action => 'index' ,
:conditions => { :method => :post },
:requirements => { :format => /csv|json/ }
###
--~--~-~--~~~---~--~~
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 with routes after upgrading to Rails 2.2.2

2008-12-30 Thread a...@s

Hello,
After I've upgraded my application to Rails 2.2.2 I get a Routing
Error:

#
 ActionController::RoutingError in Home#index

Showing app/views/application/_extjs_mainmenu.html.erb where line #19
raised:

currencies_purchases_url failed to generate from
{:controller=>"currencies_purchases", :action=>"index"} - you may have
ambiguous routes, or you may need to supply additional parameters for
this route.  content_url has the following required parameters:
["currencies_purchases", :format] - are they all satisfied?

Extracted source (around line #19):

16: new Ext.menu.Item({
17:   iconCls: 'x-menu-item-icon x-cols-icon',
18:   text: 'Currencies Purchases',
19:  href:'<%= currencies_purchases_path %>'
20: }),
21: new Ext.menu.Item({
22:   iconCls: 'x-menu-item-icon x-cols-icon',
###

Here is what I have in routes.rb:

###
 map.currencies_purchases 'currencies_purchases.:format' ,
:controller => 'currencies_purchases' ,
:action => 'index' ,
:conditions => { :method => :post },
:requirements => { :format => /csv|json/ }
###
--~--~-~--~~~---~--~~
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: Finding Child Records Efficiently

2008-12-30 Thread DAZ

Thanks or these replies Robert and Mark!

I guess that keeping the ancestors as a string in the database makes
more sense than I first thought. It is interesting that Robert refers
to this as 'caching' the family-tree, which obviously it is, but I've
not really thought of caching information like this (ie database level
relationships) before. Consequently, as Mark says it needs to be
updated whenever a name changes, which shouldn't be too difficult to
do (cycle through all the descendants and update that row?).

This has the added advantage of acting as a sort of permalink row as
well. Thinking about pretty urls, it wouldn't be too hard to use this
string to generate:

http://appname/people/abe/homer/bart

This would be the url that took you directly to Bart's url. Could I
use the '/' character as a separator at the DB level?

Robert - I really the idea of hashing the string to limit the length,
I've never thought of this as a use for hashing before, thanks!

Mark - I'm not sure what you mean by this:
> you should put the name match into the
> SQL conditions rather than in a Ruby loop.

I guess that you mean to use SQL rather than looping through ruby
arrays, but I'm afraid my SQL is very poor - I usually only use the
Rails helpers to do basic stuff.  I'm struggling to follow your
example, but I guess that it corresponds to what Philip was alluding
to by saying to construct a joins string?

..And if I used this SQL method, which would be the most
efficient? I'm erring towards the 'cached' string method at the moment
as it easily allows uniqueness validations and as I mentioned could be
used to form pretty urls.

Thanks so much again to both of you - I'm really learning lots more
than I anticipated from this thread.

cheers,

DAZ




On Dec 30, 12:33 am, Mark Reginald James  wrote:
> DAZ wrote:
> > On Dec 28, 8:07 pm, Mark Reginald James  wrote:
>
> >> One alternative is to make the ancestor array a string key
> >> to each record ("abe|homer|bart"), allowing instant retrieval.
>
> > This seems like a relatively good idea, could have a string-key called
> > family_tree or something and just do find_by_family_tree("abe|homer|
> > bart")
> > This doesn't quite feel right - it seems like the only info you should
> > need to keep is a person's parent (from which you can then find their
> > parent and so forth). It might also lead to some very long strings
> > eventually!
>
> It does require maintenance: whenever a name changes you have to
> update the string in all children and all ancestors.
>
>
>
> >> Another would be to build the sql iteratively:
>
> > This is what I'm doing at the moment - I'm using the "betternestedset"
> > plugin, so have access to a "children" method that returns an arrary
> > of children. Will this have all been pre-fetched efficiently? And if
> > so, is the iterative code the way to do it?
>
> >    tree = ["abe","homer","bart"]
> >     person = Person.find_by_name(tree[0])
> >       if tree.size > 1
> >         1.upto(tree.size - 1) do |i|
> >           person = person.children.find { |child| child.name == tree
> > [i] }
> >         end
> >       end
> >     @person = person
>
> First-generation children are efficiently retrieved in both
> better_nested_set and acts_as_tree via the parent key.
> better_nested_set also allows you to efficiently retrieve all
> generations of children using the all_children method.
>
> So your current method will be making one DB call per
> generation. And you should put the name match into the
> SQL conditions rather than in a Ruby loop.
>
> But have a look at the code in my last post. It can find
> the correct Bart using only one DB call by matching
> up the unique ancestors chain.
>
> --
> Rails Wheels - Find Plugins, List & Sell Plugins -http://railswheels.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: Help with model association

2008-12-30 Thread Petr Ruzicka

Thanks, I'll try it.

Petr

On Dec 30, 9:56 am, MaD  wrote:
> of course you can do it like this. you have acertain amount of
> workouts and trainees and add a new training every time you want. your
> models seem correct.
>
> your request would be like:
> - Workout.find(:first, :order => :elapsed_time).trainee
> ...
--~--~-~--~~~---~--~~
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: Delete All action

2008-12-30 Thread DAZ

I'd now like to take this a step further and allow users to select
which tasks they want to delete (using check boxes probably) then
select 'delete all checked tasks'. Does anybody have any pointers on
how to go about this and how the form would look? I'm guessing that I
would need to create a @selected_tasks array somehow from what was
submitted and then call delete_all on that?

cheers,

DAZ

On Dec 19, 5:20 pm, DAZ  wrote:
> Hi,
>
> What is the best way to delete all members of a model?
>
> For example I have a tasks model and want to put a link in that will
> delete all tasks at once. Something like,
>
> @tasks = Task.all
> @tasks.each { |task| task.destroy }
>
> Do I need another action for this, and what should the link to it be?
>
> cheers,
>
> DAZ
--~--~-~--~~~---~--~~
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: index => nil params jumbled *sometimes*

2008-12-30 Thread Mark Reginald James

Matt Darby wrote:
>> Those first three fields are not enclosed in a cell.
>> That may cause IE to send the parameters in the wrong order.
>>
>> Please log and post the raw_post string.
> 
> Ahh, IE, my old friend. Perhaps this is why I wasn't able to recreate
> it.

Well, I can't blame IE for tripping up on invalid HTML.

> Here is the raw POST:
> 
> Processing TimeCardsController#day (for 192.168.1.192 at 2008-12-18
> 09:14:13) [POST]
> Parameters: {"date"=>"2008-12-17", "time_cards"=>[{"job_id"=>"3107",
> "time_card_entry_type"=>"Field", "time_card_date"=>"2008-12-17",

What you really need to look at is not the params hash,
but the string posted by the browser. See this by adding
"logger.info request.raw_post" to your controller action.

If the parameters are indeed posted out of order, then the
problem was with the missing td tags. However a correct
order would instead suggest a bug in Rails' parameter processing.

-- 
Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.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: Preventing a form from submitting on ENTER

2008-12-30 Thread Mukund

Create a form without a submit tag.   Put in another control on the
web page that does $('id_of_my_form').submit(); using a javascript
onclick event or whatever.

Regards,
Mukund


sa 125 wrote:
> Hi - I have the following problem: my app has a form that acts as a
> filter to a table on the page, so that the user can search any value in
> the table (via text box) or use select lists for more specific search.
> The form is being observed by an observe_form helper that runs every 1-2
> seconds or so. It's all still in testing.
>
> I noticed that when I hit return while in the textbox, the form posts
> and redirects me to an action unknown page. I want to remove that
> functionality so that hitting enter wont do anything -- any idea how to
> do it?
>
> Thanks
> --
> 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: Equivalent ruby syntax for this query.

2008-12-30 Thread Frederick Cheung



On Dec 30, 10:10 am, Frederick Cheung 
wrote:
> On Dec 30, 10:04 am, rails and rails only 
> s.net> wrote:
> > Book.find(:all,
> >           :conditions=>["release_date >= ? and release_date < ? and
> > book_type='New'",@date[:from],@date[:to]],
> >           :group=>"auther_id",
> >           :order=>"count(*) desc",
> >           :select=>"auther_id,sum(case when auther_type = 'New' "+
> >       "then 1 else 0 end) as new,sum(case when auther_type != 'New' then
> > 1 else 0 end) as review,count(*) as total")
>
> > in the above query how to write the "case" conditions in ruby query.
>
> You can't - there are no helpers for generating complex select
> statements like that.
>
To clarify, there aren't any builtin things. There might be a third
party plugin that does this.

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: Equivalent ruby syntax for this query.

2008-12-30 Thread Frederick Cheung



On Dec 30, 10:04 am, rails and rails only  wrote:
> Book.find(:all,
>           :conditions=>["release_date >= ? and release_date < ? and
> book_type='New'",@date[:from],@date[:to]],
>           :group=>"auther_id",
>           :order=>"count(*) desc",
>           :select=>"auther_id,sum(case when auther_type = 'New' "+
>       "then 1 else 0 end) as new,sum(case when auther_type != 'New' then
> 1 else 0 end) as review,count(*) as total")
>
> in the above query how to write the "case" conditions in ruby query.

You can't - there are no helpers for generating complex select
statements like that.

Fred
>
> can anyone tell me which is the equivalent ruby syntax for this
>
> sum(case when auther_type != 'New' then 1 else 0 end) as review
>
> thanks in advance
> Jk
> --
> 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] Equivalent ruby syntax for this query.

2008-12-30 Thread rails and rails only

Book.find(:all,
  :conditions=>["release_date >= ? and release_date < ? and
book_type='New'",@date[:from],@date[:to]],
  :group=>"auther_id",
  :order=>"count(*) desc",
  :select=>"auther_id,sum(case when auther_type = 'New' "+
  "then 1 else 0 end) as new,sum(case when auther_type != 'New' then
1 else 0 end) as review,count(*) as total")



in the above query how to write the "case" conditions in ruby query.

can anyone tell me which is the equivalent ruby syntax for this

sum(case when auther_type != 'New' then 1 else 0 end) as review


thanks in advance
Jk
-- 
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] SOT: Ruby Question

2008-12-30 Thread Jeffrey L. Taylor

I have the following code.  It works but it seems to me that there must be a
clearer, more compact way.  Is there a way in Ruby to pass a method name to a
method?  Something simpler than a block or lambda?

TIA,
  Jeffrey


module Preload
  def Preload.info_msg(msg)
Preload.common_msg(msg) {|msg| RAILS_DEFAULT_LOGGER.info msg}
  end


  def Preload.debug_msg(msg)
Preload.common_msg(msg, lambda{|msg| RAILS_DEFAULT_LOGGER.debug msg})
  end


  def Preload.common_msg(msg, logger = nil)
puts msg
if logger
  logger.call(msg)
else
  yield msg
end
msg
  end
end

--~--~-~--~~~---~--~~
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] SOT: Ruby Question

2008-12-30 Thread Jeffrey L. Taylor

I have the following code.  It works but it seems to me that there must be a
clearer, more compact way.  Is there a way in Ruby to pass a method name to a
method?  Something simpler than a block or lambda?

TIA,
  Jeffrey


module Preload
  def Preload.info_msg(msg)
Preload.common_msg(msg) {|msg| RAILS_DEFAULT_LOGGER.info msg}
  end


  def Preload.debug_msg(msg)
Preload.common_msg(msg, lambda{|msg| RAILS_DEFAULT_LOGGER.debug msg})
  end


  def Preload.common_msg(msg, logger = nil)
puts msg
if logger
  logger.call(msg)
else
  yield msg
end
msg
  end
end

--~--~-~--~~~---~--~~
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 problem

2008-12-30 Thread Louis

add this inside your worker class

BG_LOGGER = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}-
background.log")

I can't rememeber where I read this but it worked for me.


On Dec 20, 12:36 pm, Marc  wrote:
> Hi all
>
> I am trying to run a background task with Starling and Workling,
> following Ryan Bates' screencast.
> My problem is that whenever I execute my async_method, nothing
> happens. No errors are generated, and the app continues as though
> nothing happened.
> My question is then, how do I debug my working? I know the ascync
> method is being called, but there is nothing in the log files and no
> degugging problems are reported. So how do I debug it?
> debugger doesnt break when called from the workling and no
> logger.debug messages from it are printed in my logs.
>
> Thanks
> Marc

--~--~-~--~~~---~--~~
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 with associations that could be null sometimes

2008-12-30 Thread cassiozen

Hi Everybody,

I'm developing a little task management system with a Task model that
belongs to Users and Projects.

The problem is that sometimes a task won't belongs to an user AND a
project. It will be possible to add a task to a project without
delegate it to any user. In a similar way, it will be possible for
users to create a new task without assigning it to any project.

So, my question is: Can I simply create the belongs_to associations
for the Task model and leave the foreign_ids empty in the cases where
the task doesn't have an user or a project? Is there a better
solution?

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] Reseting form controls

2008-12-30 Thread sa 125

How would I reset the controls on a form? I have a few text fields and
selection lists, and I want them cleared (text fields) or restored to
the top value (the :prompt in the select). I tried the code below with
render :update.

the form is in the view:

<% form_for :item, :html => { :id => 'items_form' } do |f| %>
 <%= f.text_field :name %>
 <%= f.select :available,
 [['YES','true'],['NO','false']],
 :prompt => '--Available?--' %>

<%= link_to_remote 'reset',
 :update => 'items_list',
 :url => { :action => 'reset_form' } %>

<% end %>

the action is in the controller:

def reset_form
  render :update => do |page|
page['items_form'].reset # this, um, doesn't work
  end
end

I'm new in rails, so any help will be great.
-- 
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: Preventing a form from submitting on ENTER

2008-12-30 Thread Ivor Paul
lucky you :) kudos to the staff for all using firefox

On Tue, Dec 30, 2008 at 11:26 AM, sa 125
wrote:

>
> Using and developing exclusively for firefox -- one of the benefits of
> building a site that'll only be run in an office intranet :)
>
> I'll give those a try - thanks.
> --
> 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
-~--~~~~--~~--~--~---



  1   2   >