[Rails] Re: Rakismet revisited :(

2008-11-24 Thread Rick

Hi again Schalk,

I'm assuming from the command output that you didn't succeed in
installing the plugin because here's what I see on my machine:

script/plugin -v install git://github.com/jfrench/rakismet
Plugins will be installed using http
git clone --depth 1 git://github.com/jfrench/rakismet /Users/rick/
test212/vendor/plugins/rakismet
removing: /Users/rick/test212/vendor/plugins/rakismet/.git
Initialized empty Git repository in /Users/rick/test212/vendor/plugins/
rakismet/.git/
remote: Counting objects: 45, done.
remote: Compressing objects: 100% (34/34), done.
remote: Total 45 (delta 13), reused 43 (delta 11)
Receiving objects: 100% (45/45), 10.78 KiB, done.
Resolving deltas: 100% (13/13), done.

And I get these results consistently with rails 2.1.1, 2.1.2, 2.2.0,
and 2.2.2.  So I'm thinking the problem isn't with the jfrench site.
You can confirm this by trying to grab a different plugin, say
will_paginate with

script/plugin install git://github.com/mislav/will_paginate.git

Bet that didn't work either, did it?

So I'm not sure what your problem is here but here's what I'd try.

Lets see if you can create anything in vendor/plugins.  Cd to vendor/
plugins and run git init.  Do you now have a .git directory?
If not, your problem is directory access.  Check ownership and
permissions.  Is it possible you might have run rails osd as user1
and now you're user2?

Lets see if you can install either gem in a brand new project.  So
start from rails newname. Cd into newname/ and issue the script/
plugin command.  Anything different here?

Rick


On Nov 23, 10:41 am, Schalk Neethling [EMAIL PROTECTED]
wrote:
 Hey Rick,

 Adding -v generates the following output:

 script/plugin -v install git://github.com/jfrench/rakismet
 Plugins will be installed using http
 git clone --depth 1 git://github.com/jfrench/rakismet
 C:/DEVELOPMENT/osc/vendor/plugins/rakismet
 removing: C:/DEVELOPMENT/osc/vendor/plugins/rakismet/.git

 Thanks,
 Schalk

 Rick wrote:
  Schalk,

  The install worked fine in this environment:

  Ruby version       1.8.7 (powerpc-darwin9)
  RubyGems version   1.3.1
  Rails version      2.1.2
  Active Record version      2.1.2
  Action Pack version        2.1.2
  Active Resource version    2.1.2
  Action Mailer version      2.1.2
  Active Support version     2.1.2
  Application root   /Users/rick/test212
  Environment        development
  Database adapter   sqlite3
  Database schema version    0

  I'm assuming that C:/DEVELOPMENT/osc is the root of your rails
  application.  You might try adding the -v option to plugin to see if
  you can get more information on what's happening.

  Rick

  On Nov 23, 2:56 am, Schalk Neethling [EMAIL PROTECTED] wrote:
  Hey all,

  Ok it seems that I got my one app upgraded to 2.1.2 successfully. Yeah!
  Now, when I try to install the Rakismet plugin I get the following:

  script/plugin install git://github.com/jfrench/rakismet
  script/plugin install git://github.com/jfrench/rakismet
  removing: C:/DEVELOPMENT/osc/vendor/plugins/rakismet/.git

  Basically the plugin is not installed at all :( Seems that something is
  wrong here, not sure what I am doing wrong. Also, on a slightly
  different subject, what would be the better option

  1) Continue trying until I get Rakismet working or,
  2) Rather use the Plugin and method of Railscast 
  here:http://railscasts.com/episodes/65

  Thanks again to everyone for your assistance,
  Schalk
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: how to render part of code in another one

2008-11-24 Thread Tarscher

You can't render one action in another.

What you should do is put the submit form in a partial (call it
_form.html.erb) . See http://railscasts.com/episodes/80 for more info.
In both your new and index action you put %= render :partial = @post
%. Don't forget to instantiate @post in both your index and new
controller - @post = Post.new . You ofcourse can also do this in the
partial but that's not really MVCish.

I hope this helps.
Stijn


On 24 nov, 10:01, Petan Cert [EMAIL PROTECTED] wrote:
 Hi,

 I have a simple sideblog with my posts in it. I can see 5 last posts in
 my index action. Could I add form to submit a new post at the top of my
 posts? I dont know how to render new post action in my index action to
 show the form. THX
 --
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Best approach for importing data from a file

2008-11-24 Thread Rick

Hey Richard,

Sorry it's been so long, I seem to have dropped this thread.

1) My thought about attachment_fu is that it allows you to pull files
that are local to your rails client machine and bring them into the
rails application space.  One way it's used is to enable rails users
to post their own images onto a site for sharing with the community.
There is a browser included that works much like the usual file
browser to aid with locating / selecting file for inclusion.

I'm not sure where your csv files live right now but if they're not
somewhere below RAILS_ROOT + public then you'll need to figure out
how to get them there.  Attachment_fu can help here if the files are
user generated - field data and the like - that the user will upload
into the system.

2) The next thing is moving the data into your Model(s).  I'm not sure
how comfortable you are with the quality of the data but I guarantee
that, no matter what approach you take, you'll need to constantly work
on data validation.

You'll probably do best if you start with one model for each file
type.  That way you can use the model.rb file to validate, validate,
validate,... the data on it's way to the database.

3) Of course if it's your own data and you know it's always complete
and correct, you can take the migration file approach.  It's a little
more raw than what is generally considered socially acceptable in the
RoR community.  The real drawback is then specific database methods
leak in past the abstraction boundary.  Notice the code for postgresql
differs from that for mysql - and we haven't even looked at sqlite3 or
db2 or ...:-P

class CreateStateAbbrevs  ActiveRecord::Migration
  def self.up
create_table :state_abbrevs do |t|
  t.string :name
  t.string :abbrev
end
csv_file = #{RAILS_ROOT}/db/migrate/abbr_state.csv
fields = '(name, abbrev)'

# PostgreSQL load from file...
execute COPY state_abbrevs #{fields} FROM '#{csv_file}' WITH CSV

# MySQL load from file...
# execute LOAD DATA INFILE '#{csv_file}' INTO TABLE state_abbrevs
FIELDS  +
#   TERMINATED BY ',' OPTIONALLY ENCLOSED BY   +
#   LINES TERMINATED BY '\n'  + fields

  end

  def self.down
drop_table :state_abbrevs
  end
end

So many buttons and so little time,
Rick

On Nov 13, 5:11 am, RichardOnRails
[EMAIL PROTECTED] wrote:
 HiRick,

 I've been busy, so I haven't checked for responses to my posts for a
 week or so.  Sorry for the delay in this response.

 Thanks for your response.  I just ordered Advanced Rails Recipes and
 looked at the attachment_fu.rb from the book.  I'm too weak in Rails
 to see how that's useful for my project.

 I think I've concocted a solution to my main concern: how to access a
 CVS file from the file-system from within a Rails app.  I now believe
 I can:
 1.  get the filenames housed in a specific directory from within a
 controller using normal Ruby programming.
 2.  display those filenames as a list in a view and allow the user to
 select any one of then
 3.  open the selected file and read its records, one by one
 4.  extract the fields from each cvs-formatted record and update the
 database with the contents of those fields.

 Does that sound sensible to you?

 Best wishes,
 Richard

 On Oct 27, 12:50 pm,Rick[EMAIL PROTECTED] wrote:

  Take a look at attachment_fu.

  On Oct 23, 4:23 pm, RichardOnRails

  [EMAIL PROTECTED] wrote:
   Hi All,

   I've got a basic Rails app started.  One wrinkle is that the user
   wants ideally to be able to browse the files system (a la Windows
   Explorer) to select a file and initiate the importation of data from
   the file.

   All files selected will be of a predetermined fixed format, e.g. CSV
   with Name, Address, etc.

   It seems to me that the browser is isolated from the file system,
   albeit Rails' internals know how to get to it.  Is there a way to
   implement the above-described functionality in a Rails app?  Can YAML
   be used for such functionality?

   The only approach I see right now is a Ruby database-updater using
   perhaps Active Record with ar-extensions or Active Scaffold.

   Any guidance would be most appreciated.

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



[Rails] Re: Rakismet revisited :(

2008-11-24 Thread Schalk Neethling

Ok, I now installed git using:

gem install git-rails

Successfully installed fattr-1.0.3
Successfully installed arrayfields-4.6.0
Successfully installed main-2.8.3
Successfully installed git-rails-0.2.1
Successfully installed rubyforge-1.0.1
5 gems installed
Installing ri documentation for git-rails-0.2.1...
Installing ri documentation for rubyforge-1.0.1...
Installing RDoc documentation for git-rails-0.2.1...
Installing RDoc documentation for rubyforge-1.0.1...

gem list confirms that it is installed. Tried Rakismet again:

script/plugin install git://github.com/jfrench/rakismet

No output, no error, no installation. Is there something one needs to do 
after installing the git plugin?

Thanks,
Schalk

Schalk Neethling wrote:
 hehehehe, no I don't.
 
 Frederick Cheung wrote:
 There's an obvious question: do you have git installed ? What happens  
 if you just run
 git
 from the command prompt ?

 Fred


 On 23 Nov 2008, at 20:41, Schalk Neethling wrote:

 Hey Rick,

 Adding -v generates the following output:

 script/plugin -v install git://github.com/jfrench/rakismet
 Plugins will be installed using http
 git clone --depth 1 git://github.com/jfrench/rakismet
 C:/DEVELOPMENT/osc/vendor/plugins/rakismet
 removing: C:/DEVELOPMENT/osc/vendor/plugins/rakismet/.git

 Thanks,
 Schalk

 Rick wrote:
 Schalk,

 The install worked fine in this environment:

 Ruby version   1.8.7 (powerpc-darwin9)
 RubyGems version   1.3.1
 Rails version  2.1.2
 Active Record version  2.1.2
 Action Pack version2.1.2
 Active Resource version2.1.2
 Action Mailer version  2.1.2
 Active Support version 2.1.2
 Application root   /Users/rick/test212
 Environmentdevelopment
 Database adapter   sqlite3
 Database schema version0

 I'm assuming that C:/DEVELOPMENT/osc is the root of your rails
 application.  You might try adding the -v option to plugin to see if
 you can get more information on what's happening.

 Rick

 On Nov 23, 2:56 am, Schalk Neethling [EMAIL PROTECTED]  
 wrote:
 Hey all,

 Ok it seems that I got my one app upgraded to 2.1.2 successfully.  
 Yeah!
 Now, when I try to install the Rakismet plugin I get the following:

 script/plugin install git://github.com/jfrench/rakismet
 script/plugin install git://github.com/jfrench/rakismet
 removing: C:/DEVELOPMENT/osc/vendor/plugins/rakismet/.git

 Basically the plugin is not installed at all :( Seems that  
 something is
 wrong here, not sure what I am doing wrong. Also, on a slightly
 different subject, what would be the better option

 1) Continue trying until I get Rakismet working or,
 2) Rather use the Plugin and method of Railscast 
 here:http://railscasts.com/episodes/65

 Thanks again to everyone for your assistance,
 Schalk


 
  
 

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: loops

2008-11-24 Thread Mohit Sindhwani

Smarty 2k wrote:
 hi friends

 please help me

 for (int i=0; i  total; ++i)
 {
   // do something here
 @blogid=params[:blog][:s.id]   # multiple row
 }

 Convert Ruby loops
   

I'm not sure what you are trying to do, but a primer in Ruby loops will 
help, from the look of it:
http://www.rubyist.net/~slagell/ruby/control.html
http://www.techotopia.com/index.php/Looping_with_for_and_the_Ruby_Looping_Methods

Cheers,
Mohit.
11/24/2008 | 7:14 PM.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Rakismet revisited :(

2008-11-24 Thread Schalk Neethling

Ok, I see. I have to install Git itself as well as the rails plugin 
alone will not do the trick. Doing that now.

Schalk Neethling wrote:
 Ok, I now installed git using:
 
 gem install git-rails
 
 Successfully installed fattr-1.0.3
 Successfully installed arrayfields-4.6.0
 Successfully installed main-2.8.3
 Successfully installed git-rails-0.2.1
 Successfully installed rubyforge-1.0.1
 5 gems installed
 Installing ri documentation for git-rails-0.2.1...
 Installing ri documentation for rubyforge-1.0.1...
 Installing RDoc documentation for git-rails-0.2.1...
 Installing RDoc documentation for rubyforge-1.0.1...
 
 gem list confirms that it is installed. Tried Rakismet again:
 
 script/plugin install git://github.com/jfrench/rakismet
 
 No output, no error, no installation. Is there something one needs to do 
 after installing the git plugin?
 
 Thanks,
 Schalk
 
 Schalk Neethling wrote:
 hehehehe, no I don't.

 Frederick Cheung wrote:
 There's an obvious question: do you have git installed ? What happens  
 if you just run
 git
 from the command prompt ?

 Fred


 On 23 Nov 2008, at 20:41, Schalk Neethling wrote:

 Hey Rick,

 Adding -v generates the following output:

 script/plugin -v install git://github.com/jfrench/rakismet
 Plugins will be installed using http
 git clone --depth 1 git://github.com/jfrench/rakismet
 C:/DEVELOPMENT/osc/vendor/plugins/rakismet
 removing: C:/DEVELOPMENT/osc/vendor/plugins/rakismet/.git

 Thanks,
 Schalk

 Rick wrote:
 Schalk,

 The install worked fine in this environment:

 Ruby version  1.8.7 (powerpc-darwin9)
 RubyGems version  1.3.1
 Rails version 2.1.2
 Active Record version 2.1.2
 Action Pack version   2.1.2
 Active Resource version   2.1.2
 Action Mailer version 2.1.2
 Active Support version2.1.2
 Application root  /Users/rick/test212
 Environment   development
 Database adapter  sqlite3
 Database schema version   0

 I'm assuming that C:/DEVELOPMENT/osc is the root of your rails
 application.  You might try adding the -v option to plugin to see if
 you can get more information on what's happening.

 Rick

 On Nov 23, 2:56 am, Schalk Neethling [EMAIL PROTECTED]  
 wrote:
 Hey all,

 Ok it seems that I got my one app upgraded to 2.1.2 successfully.  
 Yeah!
 Now, when I try to install the Rakismet plugin I get the following:

 script/plugin install git://github.com/jfrench/rakismet
 script/plugin install git://github.com/jfrench/rakismet
 removing: C:/DEVELOPMENT/osc/vendor/plugins/rakismet/.git

 Basically the plugin is not installed at all :( Seems that  
 something is
 wrong here, not sure what I am doing wrong. Also, on a slightly
 different subject, what would be the better option

 1) Continue trying until I get Rakismet working or,
 2) Rather use the Plugin and method of Railscast 
 here:http://railscasts.com/episodes/65

 Thanks again to everyone for your assistance,
 Schalk

 
  
 

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Single Text_Area for multiple records

2008-11-24 Thread smfrick

I have an application I've developed where there is a record of data
which is entered line by line, I've got that working fine. The form
now only has one field, because that's all the data which is
required.   I would like to make it simpler by providing a text_area,
and the user would enter a list of values and on submit have the
controller or the model parse the data into records and append them
into the table.I've looked for examples of the correct 'Rails way'
of doing this type of process, but everything looks like a single
record posted.  Does anyone know of a Gem or module which will make
this simpler?

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Public folder (images, javascript) on Amazon's Cloudfront

2008-11-24 Thread Helmut Juskewycz

Hi,

as the subject says I am currently considering to move all resources
from my app to Cloudfront.
I already googled for some best practices, but haven't found much.
However, despite that Cloudfront
is quite new, I think that many Rails developers have thought about
doing this.

As always thankful for any tips, tricks and 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Rails 2.1.2 = 2.2.2 Attempt to call private method

2008-11-24 Thread Ryan Bigg

What is the full stack trace?

On Nov 24, 10:10 pm, se_pavel [EMAIL PROTECTED] wrote:
 Hello All,

 Controller code
 -
 @dates = Q.find(:all,
 :select = 'year(q.approved_at) as y, month(q.approved_at) as m, day
 (q.approved_at) as d, count(*) as cnt',
 other conditions

 View code
 -
 % y = '' %
 % for d in @dates
                 if y.to_s != d.y.to_s

 the new rails 2.2.2 says that

 Attempt to call private method

 attribute_methods.rb:236:in `method_missing'

 How I should write my code, so I can select not only the Q table
 fields, but also calculated fields ?

 Regards,
 Pavel
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Destroy method not working (routing question)

2008-11-24 Thread Ryan Bigg

The link should be:

%= link_to Delete, admin_product_path(product), :method
= :delete, :confirm = Are you sure you want to delete this
product? %

Just to clarify: the controller you mean is admin/
products_controller.rb, right?

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Rails 2.1.2 = 2.2.2 Attempt to call private method

2008-11-24 Thread se_pavel

Is this enough ?

4: % y = '' %
5: % for d in @dates
6:if y.to_s != d.y.to_s


c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/
lib/active_record/attribute_methods.rb:236:in `method_missing'
app/views/public/dates.rhtml:6
app/views/public/dates.rhtml:5:in `each'
app/views/public/dates.rhtml:5
c:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/
action_view/renderable.rb:39:in `send'
c:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/
action_view/renderable.rb:39:in `render'
c:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/
action_view/template.rb:73:in `render_template'
c:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/
action_view/base.rb:256:in `render'
c:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/
action_view/base.rb:367:in `_render_with_layout'
c:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/
action_view/base.rb:254:in `render'
c:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/
action_controller/base.rb:1174:in `render_for_file'
c:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/
action_controller/base.rb:896:in `render_without_benchmark'
c:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/
action_controller/benchmarking.rb:51:in `render'
c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/
lib/active_support/core_ext/benchmark.rb:8:in `realtime'
c:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/
action_controller/benchmarking.rb:51:in `render'
c:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/
action_controller/base.rb:868:in `render_without_benchmark'
c:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/
action_controller/benchmarking.rb:51:in `render'
c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/
lib/active_support/core_ext/benchmark.rb:8:in `real
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: autocomplete in rails

2008-11-24 Thread Ram

http://railsforum.com/viewtopic.php?id=23273

On Nov 24, 4:01 pm, Pandu [EMAIL PROTECTED] wrote:
 Hai,

       I am venkat. I am building one application in rails. In that i
 want to implement autocomplete feature for one of my field (ex:
 Project name) instead of entering entire name which is already exist.
       So, please help me in implemention of autocomplete. How should
 we create?

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



[Rails] web service

2008-11-24 Thread Subhadip Chakraborty

 Hi,
 i am creating a server side web service in ruby on rails.
 but when i am installing gem actionwebservice, its gives an error
 actionwebservice requires actionpack(=1.13.6,runtime).
 how this problem will be solved,
 any suggestion required.Its urgent.
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: has_two, has_three, etc....

2008-11-24 Thread Joao Silva

Hello,

you could simply put in your Game model :

  belongs_to :referee_1, :class_name = 'Referee'
  belongs_to :referee_2, :class_name = 'Referee'

But the problem is in the Referee model, what you would want is :

  has_one :game

but that doesnt work because you have in fact two possible columns for 
the foreign key in the games table, leading to all the problems Clever 
Neologism mentionned.

Now if you want to be able to get the game the referee is assigned to 
(but ONLY in read mode), you could put in your Referee model :

def game
  Game.find(:first, :conditions=referee_1_id = +id.to_s+ or 
referee_2_id = +id.to_s)
end

of course the language itself doesn't make it read only... so be careful 
:)
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Rails 2.1.2 = 2.2.2 Attempt to call private method

2008-11-24 Thread se_pavel


 4: % y = '' %
 5: % for d in @dates
 6:                if y.to_s != d.y.to_s

also if I rewrite line 6 in the following way it works

6: if y != d['y'].to_s

but it requires to change a lot of code

Regards.
Pavel
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: how to render part of code in another one

2008-11-24 Thread Petan Cert

Thx for your help. Could I do the same thing (:partial =) even with 
another controller? I quess not. Thx. Pete
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] save url parameter in a session

2008-11-24 Thread PsionBlue

Hi, I am a newb.

Lets say I have url abc.com/?animal=cat. What I need to do is save the
param in the session file but still have it available to other
controllers. I can get it to work within one controller with:

session[:animal] = param[:animal]

but I cannot get it to save and be used by other controllers. I can
hack it by adding:

session[:animal] = cat

in the application.rb and adding a before filter to the controller.
How do I add a param from a url in a session to be used by all
controllers?

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: MySQL

2008-11-24 Thread Bharat

You have to have your mysql bin directory in your PATH environment
variable.  So if you installed mysql in c:\mysql then add c:\mysql\bin
to your path.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Rakismet revisited :(

2008-11-24 Thread Sazima

Schalk,

Git on Windows is a different beast, try googling for it...

Cheers, Sazima

On Nov 24, 9:07 am, Schalk Neethling [EMAIL PROTECTED] wrote:
 Ok, I now installed git using:

 gem install git-rails

 Successfully installed fattr-1.0.3
 Successfully installed arrayfields-4.6.0
 Successfully installed main-2.8.3
 Successfully installed git-rails-0.2.1
 Successfully installed rubyforge-1.0.1
 5 gems installed
 Installing ri documentation for git-rails-0.2.1...
 Installing ri documentation for rubyforge-1.0.1...
 Installing RDoc documentation for git-rails-0.2.1...
 Installing RDoc documentation for rubyforge-1.0.1...

 gem list confirms that it is installed. Tried Rakismet again:

 script/plugin install git://github.com/jfrench/rakismet

 No output, no error, no installation. Is there something one needs to do
 after installing the git plugin?

 Thanks,
 Schalk

 Schalk Neethling wrote:
  hehehehe, no I don't.

  Frederick Cheung wrote:
  There's an obvious question: do you have git installed ? What happens  
  if you just run
  git
  from the command prompt ?

  Fred

  On 23 Nov 2008, at 20:41, Schalk Neethling wrote:

  Hey Rick,

  Adding -v generates the following output:

  script/plugin -v install git://github.com/jfrench/rakismet
  Plugins will be installed using http
  git clone --depth 1 git://github.com/jfrench/rakismet
  C:/DEVELOPMENT/osc/vendor/plugins/rakismet
  removing: C:/DEVELOPMENT/osc/vendor/plugins/rakismet/.git

  Thanks,
  Schalk

  Rick wrote:
  Schalk,

  The install worked fine in this environment:

  Ruby version   1.8.7 (powerpc-darwin9)
  RubyGems version       1.3.1
  Rails version  2.1.2
  Active Record version  2.1.2
  Action Pack version    2.1.2
  Active Resource version        2.1.2
  Action Mailer version  2.1.2
  Active Support version 2.1.2
  Application root       /Users/rick/test212
  Environment    development
  Database adapter       sqlite3
  Database schema version        0

  I'm assuming that C:/DEVELOPMENT/osc is the root of your rails
  application.  You might try adding the -v option to plugin to see if
  you can get more information on what's happening.

  Rick

  On Nov 23, 2:56 am, Schalk Neethling [EMAIL PROTECTED]  
  wrote:
  Hey all,

  Ok it seems that I got my one app upgraded to 2.1.2 successfully.  
  Yeah!
  Now, when I try to install the Rakismet plugin I get the following:

  script/plugin install git://github.com/jfrench/rakismet
  script/plugin install git://github.com/jfrench/rakismet
  removing: C:/DEVELOPMENT/osc/vendor/plugins/rakismet/.git

  Basically the plugin is not installed at all :( Seems that  
  something is
  wrong here, not sure what I am doing wrong. Also, on a slightly
  different subject, what would be the better option

  1) Continue trying until I get Rakismet working or,
  2) Rather use the Plugin and method of Railscast 
  here:http://railscasts.com/episodes/65

  Thanks again to everyone for your assistance,
  Schalk
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Rails 2.1.2 = 2.2.2 Attempt to call private method

2008-11-24 Thread se_pavel


 in fact the elements in @dates are not real membes of Q, they even
 have nil value in id.
 try to use @dates = ActiveRecord::Base.connection.select_values(

this function doesn't support :first, :conditions, :joins and etc
params

Regards,
Pavel





--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: rubygems broken

2008-11-24 Thread James Mitchell

Are you sure it's not your firewall settings?

On 11/24/08, expilo [EMAIL PROTECTED] wrote:

 Hello,

 I have been trying for the last three days on two different debian
 linux platforms x386 and amd64 using different rubygems versions
 1.1.1, 1.2.0 and 1.3.1 to update gems on my system. No way! It only
 says it's  doing a bulk source update, eats all memory and does
 nothing. The longest I was waiting was 10 hours. Surely that's enough
 to update rails installation with dependencies and a couple of other
 gems  on a 1Mb cable line? It seems I'll have to learn to live with
 manual gem downloads. So my question is: how do you live without
 rubygems when you have to? Has anyone any shell scripts that use awk
 or sed, tar and wget? I'm sure they would do a better job. I'm close
 to start writing one but maybe someone already got something like
 this.

 Many thanks for any hints

 Piotr


 



-- 

--
James Mitchell

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Rails 2.1.2 = 2.2.2 Attempt to call private method

2008-11-24 Thread dctabuyz

ActiveRecord::Base.connection.select_all i meant
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Subdomain fu woes

2008-11-24 Thread [EMAIL PROTECTED]

I'm using subdomain_fu successfully and generating subdomain routes
like this:

rotues.rb:
map.city_root '',:controller = 'cities', :action =
'index', :conditions = { :subdomain = /.+/ }

using it in a view:
%= link_to city.name, city_root_path(:subdomain = city.subdomain)%

that works well, now I can't figure out how to generate a nested route
with subdomain,
i.e. miami.site.com/users/1

trying any combination of the form user_path(@user,:subdomain =
city.subdomain) does nothing excepnt append a parameter at the end of
the url like this:

site.com/users/1?subdomain=miami

help is greatly appreciated guys!
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Single Text_Area for multiple records

2008-11-24 Thread Bobnation

Perhaps, and this is just some brain dump at the moment, you could
set up a separate attribute and then use some Ruby to take that imput
and split it so that you can save it as separate attributes. I have no
idea how you would do this code wise, but having a text field set up
as :input and then attr_accesssor :input and then work from there with
some Ruby to split at newlines or with some other kind of operator.

On Nov 24, 4:57 am, smfrick [EMAIL PROTECTED] wrote:
 I have an application I've developed where there is a record of data
 which is entered line by line, I've got that working fine. The form
 now only has one field, because that's all the data which is
 required.   I would like to make it simpler by providing a text_area,
 and the user would enter a list of values and on submit have the
 controller or the model parse the data into records and append them
 into the table.    I've looked for examples of the correct 'Rails way'
 of doing this type of process, but everything looks like a single
 record posted.  Does anyone know of a Gem or module which will make
 this simpler?

 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: rubygems broken

2008-11-24 Thread Bobnation

The only time I've run into anything similar is when my internet has
either went *kaput* or a firewall setting at work stopped me from
downloading any gems automatically. I would maybe check there first.

On Nov 24, 8:15 am, expilo [EMAIL PROTECTED] wrote:
 Hello,

 I have been trying for the last three days on two different debian
 linux platforms x386 and amd64 using different rubygems versions
 1.1.1, 1.2.0 and 1.3.1 to update gems on my system. No way! It only
 says it's  doing a bulk source update, eats all memory and does
 nothing. The longest I was waiting was 10 hours. Surely that's enough
 to update rails installation with dependencies and a couple of other
 gems  on a 1Mb cable line? It seems I'll have to learn to live with
 manual gem downloads. So my question is: how do you live without
 rubygems when you have to? Has anyone any shell scripts that use awk
 or sed, tar and wget? I'm sure they would do a better job. I'm close
 to start writing one but maybe someone already got something like
 this.

 Many thanks for any hints

 Piotr
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] 2.2 Localization problem

2008-11-24 Thread Gi Ga

 I18n.locale = en
= en
 I18n.t 'date.formats.short'
I18n::MissingInterpolationArgument: interpolation argument count missing
in %b {{count}}
  from
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb:161:in
`interpolate_without_deprecated_syntax'
  from
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb:153:in
`gsub'
  from
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb:153:in
`interpolate_without_deprecated_syntax'
  from
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/i18n_interpolation_deprecation.rb:21:in
`interpolate'
  from
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/vendor/i18n-0.0.1/i18n/backend/simple.rb:41:in
`translate'
  from
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/vendor/i18n-0.0.1/i18n.rb:160:in
`t'
  from (irb):7
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Subdomain fu woes

2008-11-24 Thread [EMAIL PROTECTED]

Found the fix, it is a bug with the subdomain_fu plugin.

the solution may be found here

http://www.portallabs.com/blog/2008/10/22/fixing-subdomain_fu-with-named-routes/
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: rubygems broken

2008-11-24 Thread Frederick Cheung

You can download the .gem files yourself and install them. Since
rubygems 1.2 i've never had any problems, but prior versions were a
bit problematic (especially on machines with not so much memory)

Fred

On Nov 24, 3:04 pm, Bobnation [EMAIL PROTECTED] wrote:
 The only time I've run into anything similar is when my internet has
 either went *kaput* or a firewall setting at work stopped me from
 downloading any gems automatically. I would maybe check there first.

 On Nov 24, 8:15 am, expilo [EMAIL PROTECTED] wrote:

  Hello,

  I have been trying for the last three days on two different debian
  linux platforms x386 and amd64 using different rubygems versions
  1.1.1, 1.2.0 and 1.3.1 to update gems on my system. No way! It only
  says it's  doing a bulk source update, eats all memory and does
  nothing. The longest I was waiting was 10 hours. Surely that's enough
  to update rails installation with dependencies and a couple of other
  gems  on a 1Mb cable line? It seems I'll have to learn to live with
  manual gem downloads. So my question is: how do you live without
  rubygems when you have to? Has anyone any shell scripts that use awk
  or sed, tar and wget? I'm sure they would do a better job. I'm close
  to start writing one but maybe someone already got something like
  this.

  Many thanks for any hints

  Piotr
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: save url parameter in a session

2008-11-24 Thread Frederick Cheung


On 24 Nov 2008, at 13:13, PsionBlue wrote:


 Hi, I am a newb.

 Lets say I have url abc.com/?animal=cat. What I need to do is save the
 param in the session file but still have it available to other
 controllers. I can get it to work within one controller with:

 session[:animal] = param[:animal]

There's no reason that shouldn't work. If there's something you're  
doing wrong you haven't shown us that bit yet.

Fred

 but I cannot get it to save and be used by other controllers. I can
 hack it by adding:

 session[:animal] = cat

 in the application.rb and adding a before filter to the controller.
 How do I add a param from a url in a session to be used by all
 controllers?

 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: web service

2008-11-24 Thread Mark Thomas



On Nov 24, 7:59 am, Subhadip Chakraborty [EMAIL PROTECTED]
s.net wrote:
  Hi,
  i am creating a server side web service in ruby on rails.
  but when i am installing gem actionwebservice, its gives an error
  actionwebservice requires actionpack(=1.13.6,runtime).
  how this problem will be solved,
  any suggestion required.Its urgent.
                                 Thanks.

Actionwebservice wasn't updated for Rails 2, due to the new focus on
REST services instead. However, you may be able to get it working from
this post:

http://www.datanoise.com/articles/2008/7/2/actionwebservice-is-back

-- 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Rails::Plugin::Dependencies in rails-2.2

2008-11-24 Thread Thani Ararsu

i got Rails::Plugin::Dependencies error after updating my gem version
to rails -2.2.0

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Actionwebservice as a SOAP client to .NET services.

2008-11-24 Thread Mark Thomas

On Nov 23, 9:50 pm, Tim Uckun [EMAIL PROTECTED] wrote:
 I have read the (scant) documentation on the datanoise
 actionwebservice gems and can't figure out how you are supposed to
 structure the SOAP client.

You probably want SOAP4R. See http://rubyforge.org/projects/soap4r/
and also my tutorial at 
http://markthomas.org/2007/09/12/getting-started-with-soap4r

-- 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Rails::Plugin::Dependencies in rails-2.2

2008-11-24 Thread Frederick Cheung



On Nov 24, 3:35 pm, Thani Ararsu [EMAIL PROTECTED]
wrote:
 i got Rails::Plugin::Dependencies error after updating my gem version
 to rails -2.2.0

 any idea?

Not without more details.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Single Text_Area for multiple records

2008-11-24 Thread smfrick

That's a great Idea,  It's the How I'm trying to figure out.  This is
a simple task in PHP or ASP, but Ruby is a different animal
completely, and I don't want to buck the system.  Thanks for your
input.

On Nov 24, 8:42 am, Bobnation [EMAIL PROTECTED] wrote:
 Perhaps, and this is just some brain dump at the moment, you could
 set up a separate attribute and then use some Ruby to take that imput
 and split it so that you can save it as separate attributes. I have no
 idea how you would do this code wise, but having a text field set up
 as :input and then attr_accesssor :input and then work from there with
 some Ruby to split at newlines or with some other kind of operator.

 On Nov 24, 4:57 am, smfrick [EMAIL PROTECTED] wrote:

  I have an application I've developed where there is a record of data
  which is entered line by line, I've got that working fine. The form
  now only has one field, because that's all the data which is
  required.   I would like to make it simpler by providing a text_area,
  and the user would enter a list of values and on submit have the
  controller or the model parse the data into records and append them
  into the table.    I've looked for examples of the correct 'Rails way'
  of doing this type of process, but everything looks like a single
  record posted.  Does anyone know of a Gem or module which will make
  this simpler?

  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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Can't seem to map a route as GET for controller/search/term

2008-11-24 Thread Robert Kosek

Hi all,

I'm making a search features for a record with a keywords field
(keywords is a string right now), and my routing is having consistency
troubles.  What I desire is:
 localhost:3000/controller/search/:keyword

I would like this form to be obeyed for both form-submitted searches and
the HTML links I generate.  However, :method = :get is not being
obeyed, and my helper method returns search?keyword=foo+bar.

My routing is RESTful, and I have added the search action to the
map.resources call.  If I call controller/search/keyword directly I
get this error:
 undefined method `index_url' for #SermonsController:0x4a0e1c4

I find this curious.  My routing is before the map.connect call for the
standard format.

Here's my map call:
  map.resources :sermons, :collection = { :search = :get }

If I map the following line, I get a 500 error.
  map.search_sermons 'sermons/search/:keyword',
   :controller = :sermons, :action = :search

As you can guess this is confusing me.

Have I done anything wrong?  My links are forced into the
controller/search?keyword=foo+bar format, and my forms remain POST
methods no matter what I try to override them with.  How should I go
about routing this?

Thanks,
Robert

P.S.  I currently have the site working with what I have, but I'd really
like to make it consistent with the rest of the site's routing scheme.
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: MySQL

2008-11-24 Thread Mr. Watson

I did that and it worked. But I type in the rake db:migrate command
and it tells me  Access denied for user '[EMAIL PROTECTED]' 

On Nov 24, 7:36 am, Sazima [EMAIL PROTECTED] wrote:
 Elementary, my dear Watson :-)

 Copy the dll to c:\windows or add it to your path.

 -http://forums.mysql.com/read.php?52,37151,192816
 -http://hillemania.wordpress.com/2006/09/21/rails-mysql-50-on-windows-...

 Also, Google is much better than Sherlock Holmes...

 Cheers, Sazima

 On Nov 24, 5:28 am, Mr. Watson [EMAIL PROTECTED] wrote:

  I try the command rake db:migrate and it tells me it cannot find
  libmysql.dll file.

  On Nov 24, 1:02 am, Mr. Watson [EMAIL PROTECTED] wrote:

   It will let me go into mysql but I want to create a database. It is
   not letting me. It says install gem mysql... I did that and got an
   error. It reads While generating documentation for mysql... MESSAGE:
   Unhandled special: Special: type=17... etc

   On Nov 24, 12:45 am, Mr. Watson [EMAIL PROTECTED] wrote:

the command mysql -u root worked for me.

Thanks,

On Nov 24, 12:37 am, Mr. Watson [EMAIL PROTECTED] wrote:

 Nothing. It just gives me the help list.

 On Nov 24, 12:31 am, Simon Macneall [EMAIL PROTECTED] wrote:

  Hi,

  Remove the space between the -p and root

  ie mysqladmin -u root -proot

  Simon

  On Mon, 24 Nov 2008 15:27:07 +0900, Mr. Watson [EMAIL PROTECTED]  
  wrote:

   Hello,

   I am having problems with MySQL.

   Running: PC with Windows Vista
   Installed: Instant Rails AND RoR on (http://www.rubyonrails.com)

   I have edited the database.yml file.

   I went to C:/InstantRails/mysql/binmysqladmin -u root -p root

   And it says password:.

   I press enter and it shoots this error.

mysqladmin: Unknown command: 'root' 

   Any ideas?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: calling a partial from within a model / model's method?

2008-11-24 Thread Nick Hoffman

On 2008-11-24, at 08:37, Joel Oliveira wrote:
 Hey Nick!

 First - thanks for the reply.

 Second - the reason why I'm trying to do this is to allow whatever  
 type of widget model I'm creating to render its own particular  
 partial, in the context of the area a user will place it - header,  
 footer, sidebar, etc.   I thought that calling a helper to weed out  
 the objects for a particular area and then letting the model call  
 its partial on its own, would be the easier way to do it, despite  
 the normal MVC rules.  I know it's against the rules - so I'm  
 wondering if there's an easier way?

 Any input would be appreciated! :)

 Thanks!

 - Joel

Hi Joel. Why not create a helper method that determines which partial  
should be rendered? For example:
   http://pastie.org/pastes/322615

-Nick

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Sqlite3 no longer found after upgrading to Rails 2.2 on MacOS

2008-11-24 Thread Matt

 I have to wonder if this was done on purpose as a sort
of sabotage, since there is this religious war going on with Merb and
Rails. 

Wow, that's some serious accusations there.

First off, DataMapper is not developed by the Merb team. do_sqlite3 is
a separate driver letting you use DM and Sqlite3. In the Rails world,
ActiveRecord deals with the various drivers by knowing a lot about
them and their APIs. In the DataMapper world, the drivers were re
written to match the DataObject API (so DM doesn't have to figure out
how each adapter/driver works).

If the problem you're having can be reproduced that means few things.
First, you wouldn't be able to use ActiveRecord/Rails and DataMapper
on the same system using Sqlite3. DataMapper is used by other
frameworks/scripts than Merb and some people even hack Rails to use
DM. Secondly ActiveRecord nor DM should touch sqlite3 so it seems
pretty strange. On windows, both frameworks do require a sqlite3.dll
to be available on the system and they might fight over which version
to use but you seem to be on MacOSX.

Regarding the religious war you are referring to, I don't know why
you say that. As a Merb team member I can assure you that there is not
such a thing. We do not agree on the way Rails does few things, but
there is no war. And it is certainly not something personal. As
mentioned before, we have a lot of respect for DHH and the rest of the
Rails team. Without them, I wouldn't do what I do now and Merb would
not even exist. So, please don't mention some crazy sabotage theories
and maybe people will stop thinking that there is a war going on.

Finally, while I was replying to your messages, I installed Rails
2.2.2, upgraded mongrel to 1.1.5 and made sure I was on DM 0.9.7 with
do_sqlite3 0.9.7 and I can't reproduce your problem.

If you upload a test app, I'd be glad to look at it and try to figure
out what's going on.

Thanks,

-Matt


On Nov 22, 1:31 pm, ncancelliere [EMAIL PROTECTED] wrote:
 Ok - I found out what it was ... damn Merb!!

     do_sqlite3-0.9.7

 After I removed this gem (which is a dependency installed by Merb)
 everything went back to working right.  I reinstalled the gem, and I
 get the same error again.  So there's something going on between Rails
 and this particular gem - although I'm not smart enough to figure out
 what, nor have time to.

 So if you're running into the same issue I would just take out that
 gem - but it probably means you can't use SQLite with your Merb
 applications.  I have to wonder if this was done on purpose as a sort
 of sabotage, since there is this religious war going on with Merb and
 Rails.

 On Nov 22, 7:48 am, ncancelliere [EMAIL PROTECTED] wrote:

  I've updated to the Rails 2.2 gem and now I can't run Rails because I
  get an error it cannot find SQLite3.  I was running just fine under
  2.1.2 with SQlite3.  I'm on a Mac OS X 10.5 (Leopard) system.

   gem list rails

  rails (2.2.2, 2.1.2, 2.0.2)
  rails-app-installer (0.2.0)

   gem list sqlite

  sqlite3-ruby (1.2.4)

   which sqlite3

  /usr/bin/sqlite3

  I know SQLite is installed and working because I can go into it from
  the command line.  For some reason though Rails is not able to find
  it.  Any ideas on how to fix this?  (I've already tried reinstalling
  sqlite3-ruby - sudo gem install sqlite3-ruby, but that doesn't 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Rails 2.1.2 = 2.2.2 Attempt to call private method

2008-11-24 Thread se_pavel

 Don't call it y. There's already a method on object called y (seems to  
 do yaml dumps). You might be able to get round that with

 class Q  ActiveRecord::Base
   undef_method :y
 # rest of that class here
 end

yes, you are right .. I have renamed y to year and it works

Regards,
Pavel
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Date Comparison Problems

2008-11-24 Thread Charley Mills

I'm trying to compare two dates (one from a database, and the other is
the current date).  Here is the code I'm using:

--
if document.nil?
  doc_none
elsif document.status == 'archived'
  doc_archived
elsif document.expiration_on  720.days.ago
  doc_expired_720
elsif document.expiration_on  360.days.ago
  doc_expired_360
elsif document.expiration_on  90.days.ago
  doc_expired_90
elsif document.expiration_on  60.days.ago
  doc_expired_60
elsif document.expiration_on  30.days.ago
  doc_expired_30
elsif document.expiration_on  0.days.ago
  doc_expired
elsif document.expiration_on  30.days.from.now
 doc_expiring_30
elsif document.expiration_on  60.days.from.now
  doc_expiring_60
else
  doc_current
end
--

Here is the error in my log:

--
ActionView::TemplateError (comparison of Date with Time failed) on line
#46 of app/views/admin/documents/list.rhtml:
43:   tr
44: td%= link_to
document.expiration_on.strftime(%Y.%m.%d), :action = 'show', :id =
document %/td
45: td%= link_to_organization(document.organization)
%/td
46: td class=%= expiration_class(document) %
47: %=hh document.status_readable
% /td
48: td%= link_to_doctype(document.doctype) %/td
49: td%= link_to document.service_date.strftime(%Y.%m.%d),
:action = 'show', :id = document %/td

#{RAILS_ROOT}/app/helpers/organizations_helper.rb:12:in `'
#{RAILS_ROOT}/app/helpers/organizations_helper.rb:12:in
`expiration_class'
#{RAILS_ROOT}/app/views/admin/documents/list.rhtml:46
#{RAILS_ROOT}/app/views/admin/documents/list.rhtml:42:in `each'
#{RAILS_ROOT}/app/views/admin/documents/list.rhtml:42
--

It sounds like my dates aren't in the same format, but I'm not sure what
the solution is.  I'm using mySQL, and the field that I'm grabbing the
data from is of type date.
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] using variables as FRAME links

2008-11-24 Thread Jason

I have a main page that calls a sub page (see code below) and in the
controller I just set link1, link2, and link3 to be some hard coded
test pages, but when i view the frames page below all the frames are
empty. If I move the hard code links into the place of link1,2,3 then
it works fine, but i want to use variables as I want the frames to
display different things depentent on user variables. Does this make
sense? Thanks


!DOCTYPE html PUBLIC -//W3C//DTD HTML 4.0 FRAMESET //EN
html

frameset cols=33%,33%,33%

   frame src=%= @link1 %
   frame src=%= @link2 %
   frame src=%= @link3 %

   NOFRAMES
  bodyFrames Not Supported/body
   /NOFRAMES

/frameset

/html

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: MySQL

2008-11-24 Thread Hassan Schroeder

On Mon, Nov 24, 2008 at 8:25 AM, Mr. Watson [EMAIL PROTECTED] wrote:

 I did that and it worked. But I type in the rake db:migrate command
 and it tells me  Access denied for user '[EMAIL PROTECTED]' 

You need to configure config/database.yml with the appropriate
access information (username, password, etc.) for your DB.

-- 
Hassan Schroeder  [EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Automatically updating the localization dictionaries

2008-11-24 Thread Karl Eklund

With gettext-rails, I could do rake updatepo to automatically scan
my views and controllers for localizable messages and update my .po
files. As gettext-rails stopped working with Rails 2.2, I decided to
switch to the built-in I18n system, but I'm missing that
functionality. Is there some similar method now?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Strange Issue w/ incorrect controller invocation for nested routes using the same controller name...

2008-11-24 Thread John Trupiano

Also, worth noting that the app is running rails 2.1.0 currently.  I
also had this problem when it was previously running 2.0.2.  Upgrading
to 2.1.2 is potentially an option, but I'm wary of just trying
something like that in production when I don't fully understand what
the problem is, so I'm holding off on that in the meantime.


-John

On Nov 24, 12:39 pm, John Trupiano [EMAIL PROTECTED] wrote:
 Hi, I've been battling a very strange and irritating bug for a long
 time now.  The issue is the following:

 I have namespaced my controllers in routes.rb
  * map.resources :login, :collection = [:login, :logout]
  * map.namespace :partner do |p|
       p.resources :login, :collection = [:login, :logout]
     end

 As such, I have two distinct controllers app/controllers/
 login_controller and app/controllers/partner/login_controller.

 I'm running Apache + Passenger 2.0.3.  When apache is freshly
 restarted, requests to /partner/login invoke the proper controller.
 However, after some period of time (or some series of
 actionswhatever it is, I cannot isolate it), the wrong controller
 will be invoked when requesting /partner/login.

 Reaching back into my logs, I see no difference in the logging that
 rails performed.

 *** Log entry before bug starts showing up

 Processing LoginController#index (for xx.xx.xx.xx at 2008-11-24
 10:33:26) [GET]
   Session ID: bb63a070c1fa56a703018fa922359146
   Parameters: {action=index, controller=partner/login}
 Rendering template within layouts/application
 Rendering partner/login/index
 Completed in 0.00188 (531 reqs/sec) | Rendering: 0.00178 (94%) | DB:
 0.00180 (95%) | 200 OK [https://myapp/partner/login]

 *** Log entry after bug has started showing up

 Processing LoginController#index (for xx.xx.xx.xx at 2008-11-24
 12:26:35) [GET]
   Session ID: 5bdeff99bd72fe94cb8b80fd9b6beff6
   Parameters: {action=index, controller=partner/login}
 Rendering template within layouts/static_dashboard
 Rendering login/index
 Completed in 0.00286 (349 reqs/sec) | Rendering: 0.00274 (95%) | DB:
 0.00429 (150%) | 200 OK [https://myapp/partner/login]

 What kills me is that in parameters, the proper controller/action are
 being identified.  But if you look at the succeeding lines, you'll see
 different templates being rendered.

 This has been happening to me for quite a while.  Even prior to moving
 to Passenger quite a while ago, I saw this same bug crop up in
 production when using a mongrel_cluster solution behind Pound.  So I'm
 fairly certain that it's not related to Passenger.  I have not seen it
 arise in my local dev environment (running mongrel).

 I realize this is quite the shot in the dark, but I was curious if
 anyone had any thoughts whatsoever on the source of this problem, or
 if you've encountered anything similar in the past.

 Thanks for any help.

 -John
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] How to make named_scope aware of association context?

2008-11-24 Thread Sven

Given these models

  class Category  ActiveRecord
has_many :category_assignments
has_many :posts, :through = :category_assignments
  end

  class CategoryAssignment  ActiveRecord::Base
belongs_to :post
belongs_to :category
# Has boolean column 'featured'
  end

  class Post  ActiveRecord::Base
has_many :category_assignments
has_many :categories, :through = :category_assignments
  end

I want to add a named_scope to Post that will return all featured
posts. But the semantics of this named_scope vary depending upon
whether I am calling the named scope on Post or on category.posts:
  Post.featured
is simple enough. The definition
  named_scope :featured,
  :joins = :category_assignments,
  :conditions = {:category_assignments.featured = true }
will return all posts for which any associated category_assignment
record has featured = true.

But when I take a category instance and call category.posts.featured I
want to get all of the posts which are featured *in that category*,
which requires restricting by category_id. To do this properly the
named_scope code needs to be able to determine whether it's being
called in a context in which category_assignments has already been
joined (and/or whether a category_id is specified in the conditions).
I have not figured out how to do this.

If I can detect whether or not the named_scope is being called within
the context of an association then I can do something like the
following, which changes named_scope semantics based on whether or not
a category _argument_ is explicitly provided:

  named_scope :featured, lambda { |*args|
if (category = args.first)
  { :joins = :category_assignments,
:conditions = {:category_id = category.id,
:featured= true} }
else
  { :joins = :category_assignments,
:conditions = {:featured= true} }
end
  }

Is there some way to inspect a joins or conditions hash to determine
association state from within a named_scope? And if so, is it reliable
regardless of the order of named_scope stacking (i.e. will it work for
either category.posts.other.named.scopes.featured or
category.posts.featured.other.named.scopes)?

Thanks,

Sven
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: strange behavior of expire_fragment

2008-11-24 Thread Ar Chron

Have you determined what

   %r{.*}

evaluates to in the context of your Sweeper?
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Checking if Image file exists before displaying it?

2008-11-24 Thread Corey Murphy

I want a page to display an image for a record if the image file
actually exists. If the file does not exist (newly created record) I
want the placeholder image to display. I've tried using File.exist? as
my conditional but it fails to find the files that do exist.  Any ideas
how to easily handle this at the view code level?


View Code:

% for e in @media_elements %
 % if File.exist?(e.filename) %
 %= link_to(image_tag(e.filename.to_s) -%
 % else %
 %= link_to(image_tag(placeholder_image.jpg) -%
 % 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: rubygems broken

2008-11-24 Thread Frederick Cheung


On 24 Nov 2008, at 17:54, expilo wrote:


 So what  RAM size would you recommend? If 512MB is too little another
 tool is really needed, at least for those on low memory VPSs.


I don't honestly know, but what I was trying to say is that that  
problem has gone away since rubygems 1.2. If you've still got that  
problem then it's something else
 Piotr

 On 24 Lis, 18:41, Frederick Cheung [EMAIL PROTECTED] wrote:
 On 24 Nov 2008, at 17:33, expilo wrote:



 I got 512 MB. Maybe that's too little? I don't think it's the  
 internet
 problem. I can downloadhttp://gems.rubyforge.org/yaml(27 M) with
 wget in 3 min 46 s.

 You might well be under pressure with that much ram. I've never had
 that problem since rubygems 1.2

 Fred

 Piotr

 On 24 Lis, 16:15, Frederick Cheung [EMAIL PROTECTED]  
 wrote:
 You can download the .gem files yourself and install them. Since
 rubygems 1.2 i've never had any problems, but prior versions were a
 bit problematic (especially on machines with not so much memory)

 Fred

 On Nov 24, 3:04 pm, Bobnation [EMAIL PROTECTED] wrote:

 The only time I've run into anything similar is when my internet  
 has
 either went *kaput* or a firewall setting at work stopped me from
 downloading any gems automatically. I would maybe check there  
 first.

 On Nov 24, 8:15 am, expilo [EMAIL PROTECTED] wrote:

 Hello,

 I have been trying for the last three days on two different  
 debian
 linux platforms x386 and amd64 using different rubygems versions
 1.1.1, 1.2.0 and 1.3.1 to update gems on my system. No way! It  
 only
 says it's  doing a bulk source update, eats all memory and does
 nothing. The longest I was waiting was 10 hours. Surely that's
 enough
 to update rails installation with dependencies and a couple of
 other
 gems  on a 1Mb cable line? It seems I'll have to learn to live  
 with
 manual gem downloads. So my question is: how do you live without
 rubygems when you have to? Has anyone any shell scripts that use
 awk
 or sed, tar and wget? I'm sure they would do a better job. I'm
 close
 to start writing one but maybe someone already got something like
 this.

 Many thanks for any hints

 Piotr
 


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Strange Issue w/ incorrect controller invocation for nested routes using the same controller name...

2008-11-24 Thread Frederick Cheung


On 24 Nov 2008, at 17:41, John Trupiano wrote:


 Also, worth noting that the app is running rails 2.1.0 currently.  I
 also had this problem when it was previously running 2.0.2.  Upgrading
 to 2.1.2 is potentially an option, but I'm wary of just trying
 something like that in production when I don't fully understand what
 the problem is, so I'm holding off on that in the meantime.

Are the classes both named LoginController or is one of them  
Partner::LoginController ?

Fred



 -John

 On Nov 24, 12:39 pm, John Trupiano [EMAIL PROTECTED] wrote:
 Hi, I've been battling a very strange and irritating bug for a long
 time now.  The issue is the following:

 I have namespaced my controllers in routes.rb
  * map.resources :login, :collection = [:login, :logout]
  * map.namespace :partner do |p|
   p.resources :login, :collection = [:login, :logout]
 end

 As such, I have two distinct controllers app/controllers/
 login_controller and app/controllers/partner/login_controller.

 I'm running Apache + Passenger 2.0.3.  When apache is freshly
 restarted, requests to /partner/login invoke the proper controller.
 However, after some period of time (or some series of
 actionswhatever it is, I cannot isolate it), the wrong controller
 will be invoked when requesting /partner/login.

 Reaching back into my logs, I see no difference in the logging that
 rails performed.

 *** Log entry before bug starts showing up

 Processing LoginController#index (for xx.xx.xx.xx at 2008-11-24
 10:33:26) [GET]
   Session ID: bb63a070c1fa56a703018fa922359146
   Parameters: {action=index, controller=partner/login}
 Rendering template within layouts/application
 Rendering partner/login/index
 Completed in 0.00188 (531 reqs/sec) | Rendering: 0.00178 (94%) | DB:
 0.00180 (95%) | 200 OK [https://myapp/partner/login]

 *** Log entry after bug has started showing up

 Processing LoginController#index (for xx.xx.xx.xx at 2008-11-24
 12:26:35) [GET]
   Session ID: 5bdeff99bd72fe94cb8b80fd9b6beff6
   Parameters: {action=index, controller=partner/login}
 Rendering template within layouts/static_dashboard
 Rendering login/index
 Completed in 0.00286 (349 reqs/sec) | Rendering: 0.00274 (95%) | DB:
 0.00429 (150%) | 200 OK [https://myapp/partner/login]

 What kills me is that in parameters, the proper controller/action are
 being identified.  But if you look at the succeeding lines, you'll  
 see
 different templates being rendered.

 This has been happening to me for quite a while.  Even prior to  
 moving
 to Passenger quite a while ago, I saw this same bug crop up in
 production when using a mongrel_cluster solution behind Pound.  So  
 I'm
 fairly certain that it's not related to Passenger.  I have not seen  
 it
 arise in my local dev environment (running mongrel).

 I realize this is quite the shot in the dark, but I was curious if
 anyone had any thoughts whatsoever on the source of this problem, or
 if you've encountered anything similar in the past.

 Thanks for any help.

 -John
 


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: rubygems broken

2008-11-24 Thread expilo

So what  RAM size would you recommend? If 512MB is too little another
tool is really needed, at least for those on low memory VPSs.

Piotr

On 24 Lis, 18:41, Frederick Cheung [EMAIL PROTECTED] wrote:
 On 24 Nov 2008, at 17:33, expilo wrote:



  I got 512 MB. Maybe that's too little? I don't think it's the internet
  problem. I can downloadhttp://gems.rubyforge.org/yaml(27 M) with
  wget in 3 min 46 s.

 You might well be under pressure with that much ram. I've never had  
 that problem since rubygems 1.2

 Fred

  Piotr

  On 24 Lis, 16:15, Frederick Cheung [EMAIL PROTECTED] wrote:
  You can download the .gem files yourself and install them. Since
  rubygems 1.2 i've never had any problems, but prior versions were a
  bit problematic (especially on machines with not so much memory)

  Fred

  On Nov 24, 3:04 pm, Bobnation [EMAIL PROTECTED] wrote:

  The only time I've run into anything similar is when my internet has
  either went *kaput* or a firewall setting at work stopped me from
  downloading any gems automatically. I would maybe check there first.

  On Nov 24, 8:15 am, expilo [EMAIL PROTECTED] wrote:

  Hello,

  I have been trying for the last three days on two different debian
  linux platforms x386 and amd64 using different rubygems versions
  1.1.1, 1.2.0 and 1.3.1 to update gems on my system. No way! It only
  says it's  doing a bulk source update, eats all memory and does
  nothing. The longest I was waiting was 10 hours. Surely that's  
  enough
  to update rails installation with dependencies and a couple of  
  other
  gems  on a 1Mb cable line? It seems I'll have to learn to live with
  manual gem downloads. So my question is: how do you live without
  rubygems when you have to? Has anyone any shell scripts that use  
  awk
  or sed, tar and wget? I'm sure they would do a better job. I'm  
  close
  to start writing one but maybe someone already got something like
  this.

  Many thanks for any hints

  Piotr
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: save url parameter in a session

2008-11-24 Thread PsionBlue

So sessions are not cleared out controller to controller? I found
another way (prob. a better way), I am using the redirect_to to pass
the variable. The funny thing about problems is that you need to know
what the question is before you can solve it I guess... 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to make named_scope aware of association context?

2008-11-24 Thread Sven Aas
On Mon, Nov 24, 2008 at 12:49 PM, Frederick Cheung 
[EMAIL PROTECTED] wrote:

 It should do that by itself. You shouldn't need to do anything. Have
 you tried it?

 Fred


Yes, with code like this:

  named_scope :featured, :joins = :category_assignments,
   :conditions = ['category_assignments.featured = ?',
true ]

When I call

  Post.featured

it works fine. But when I call, category.posts.featured I get

  ActiveRecord::StatementInvalid: SQLite3::SQLException: ambiguous column
name: category_assignments.post_id

because Rails generates this query:

  SELECT posts.* FROM posts
  INNER JOIN category_assignments ON category_assignments.post_id =
post.id
  INNER JOIN category_assignments ON posts.id =
category_assignments.post_id
  WHERE ((category_assignments.category_id = 1))
  AND   ((category_assignments.featured = 't'))

As you can see, category_assignments is being joined twice. The named_scope
needs to omit the category_assignments join when it gets called on a
Category instance.

I'm running this on Rails 2.1.1, by the way.

-Sven

PS: there was an error in my initial post. I specified
  :conditions = {:category_assignments.featured = true }
where I ought to have written
  :conditions = ['category_assignments.featured = ?', true]

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to make named_scope aware of association context?

2008-11-24 Thread Frederick Cheung



On Nov 24, 5:43 pm, Sven [EMAIL PROTECTED] wrote:
 Given these models

   class Category  ActiveRecord
     has_many :category_assignments
     has_many :posts, :through = :category_assignments
   end

   class CategoryAssignment  ActiveRecord::Base
     belongs_to :post
     belongs_to :category
     # Has boolean column 'featured'
   end

   class Post  ActiveRecord::Base
     has_many :category_assignments
     has_many :categories, :through = :category_assignments
   end

 I want to add a named_scope to Post that will return all featured
 posts. But the semantics of this named_scope vary depending upon
 whether I am calling the named scope on Post or on category.posts:
   Post.featured
 is simple enough. The definition
   named_scope :featured,
               :joins = :category_assignments,
               :conditions = {:category_assignments.featured = true }
 will return all posts for which any associated category_assignment
 record has featured = true.

 But when I take a category instance and call category.posts.featured I
 want to get all of the posts which are featured *in that category*,
 which requires restricting by category_id. To do this properly the

It should do that by itself. You shouldn't need to do anything. Have
you tried it?

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Sqlite3 no longer found after upgrading to Rails 2.2 on MacOS

2008-11-24 Thread Matt

Alright, so after few minutes working with some of the Rails guys and
some other Ruby experts like Evan Phoenix, we found the problem. The
source is that do_sqlite3 ships with a windows dll called sqlite3.dll
and that Ruby was trying to load this file instead of the proper lib.

Libs should be properly namespaced but in this case, that's really a
DM/do problem and I believe it should be fixed relatively soon.

Thanks for reporting the bug tho.

-Matt


On Nov 24, 12:15 pm, Matt [EMAIL PROTECTED] wrote:
 My bad, akita from AkitaOnRails.com  told me how to reproduce the
 problem.

 1. generate a new app
 2. rake db:migrate

 Fails

 I'll look into it or get someone to look into it.

 - Matt

 On Nov 24, 12:04 pm, Matt [EMAIL PROTECTED] wrote:

   I have to wonder if this was done on purpose as a sort
  of sabotage, since there is this religious war going on with Merb and
  Rails. 

  Wow, that's some serious accusations there.

  First off, DataMapper is not developed by the Merb team. do_sqlite3 is
  a separate driver letting you use DM and Sqlite3. In the Rails world,
  ActiveRecord deals with the various drivers by knowing a lot about
  them and their APIs. In the DataMapper world, the drivers were re
  written to match the DataObject API (so DM doesn't have to figure out
  how each adapter/driver works).

  If the problem you're having can be reproduced that means few things.
  First, you wouldn't be able to use ActiveRecord/Rails and DataMapper
  on the same system using Sqlite3. DataMapper is used by other
  frameworks/scripts than Merb and some people even hack Rails to use
  DM. Secondly ActiveRecord nor DM should touch sqlite3 so it seems
  pretty strange. On windows, both frameworks do require a sqlite3.dll
  to be available on the system and they might fight over which version
  to use but you seem to be on MacOSX.

  Regarding the religious war you are referring to, I don't know why
  you say that. As a Merb team member I can assure you that there is not
  such a thing. We do not agree on the way Rails does few things, but
  there is no war. And it is certainly not something personal. As
  mentioned before, we have a lot of respect for DHH and the rest of the
  Rails team. Without them, I wouldn't do what I do now and Merb would
  not even exist. So, please don't mention some crazy sabotage theories
  and maybe people will stop thinking that there is a war going on.

  Finally, while I was replying to your messages, I installed Rails
  2.2.2, upgraded mongrel to 1.1.5 and made sure I was on DM 0.9.7 with
  do_sqlite3 0.9.7 and I can't reproduce your problem.

  If you upload a test app, I'd be glad to look at it and try to figure
  out what's going on.

  Thanks,

  -Matt

  On Nov 22, 1:31 pm, ncancelliere [EMAIL PROTECTED] wrote:

   Ok - I found out what it was ... damn Merb!!

       do_sqlite3-0.9.7

   After I removed this gem (which is a dependency installed by Merb)
   everything went back to working right.  I reinstalled the gem, and I
   get the same error again.  So there's something going on between Rails
   and this particular gem - although I'm not smart enough to figure out
   what, nor have time to.

   So if you're running into the same issue I would just take out that
   gem - but it probably means you can't use SQLite with your Merb
   applications.  I have to wonder if this was done on purpose as a sort
   of sabotage, since there is this religious war going on with Merb and
   Rails.

   On Nov 22, 7:48 am, ncancelliere [EMAIL PROTECTED] wrote:

I've updated to the Rails 2.2 gem and now I can't run Rails because I
get an error it cannot find SQLite3.  I was running just fine under
2.1.2 with SQlite3.  I'm on a Mac OS X 10.5 (Leopard) system.

 gem list rails

rails (2.2.2, 2.1.2, 2.0.2)
rails-app-installer (0.2.0)

 gem list sqlite

sqlite3-ruby (1.2.4)

 which sqlite3

/usr/bin/sqlite3

I know SQLite is installed and working because I can go into it from
the command line.  For some reason though Rails is not able to find
it.  Any ideas on how to fix this?  (I've already tried reinstalling
sqlite3-ruby - sudo gem install sqlite3-ruby, but that doesn't 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Sqlite3 no longer found after upgrading to Rails 2.2 on MacOS

2008-11-24 Thread Matt

My bad, akita from AkitaOnRails.com  told me how to reproduce the
problem.

1. generate a new app
2. rake db:migrate

Fails

I'll look into it or get someone to look into it.

- Matt

On Nov 24, 12:04 pm, Matt [EMAIL PROTECTED] wrote:
  I have to wonder if this was done on purpose as a sort
 of sabotage, since there is this religious war going on with Merb and
 Rails. 

 Wow, that's some serious accusations there.

 First off, DataMapper is not developed by the Merb team. do_sqlite3 is
 a separate driver letting you use DM and Sqlite3. In the Rails world,
 ActiveRecord deals with the various drivers by knowing a lot about
 them and their APIs. In the DataMapper world, the drivers were re
 written to match the DataObject API (so DM doesn't have to figure out
 how each adapter/driver works).

 If the problem you're having can be reproduced that means few things.
 First, you wouldn't be able to use ActiveRecord/Rails and DataMapper
 on the same system using Sqlite3. DataMapper is used by other
 frameworks/scripts than Merb and some people even hack Rails to use
 DM. Secondly ActiveRecord nor DM should touch sqlite3 so it seems
 pretty strange. On windows, both frameworks do require a sqlite3.dll
 to be available on the system and they might fight over which version
 to use but you seem to be on MacOSX.

 Regarding the religious war you are referring to, I don't know why
 you say that. As a Merb team member I can assure you that there is not
 such a thing. We do not agree on the way Rails does few things, but
 there is no war. And it is certainly not something personal. As
 mentioned before, we have a lot of respect for DHH and the rest of the
 Rails team. Without them, I wouldn't do what I do now and Merb would
 not even exist. So, please don't mention some crazy sabotage theories
 and maybe people will stop thinking that there is a war going on.

 Finally, while I was replying to your messages, I installed Rails
 2.2.2, upgraded mongrel to 1.1.5 and made sure I was on DM 0.9.7 with
 do_sqlite3 0.9.7 and I can't reproduce your problem.

 If you upload a test app, I'd be glad to look at it and try to figure
 out what's going on.

 Thanks,

 -Matt

 On Nov 22, 1:31 pm, ncancelliere [EMAIL PROTECTED] wrote:

  Ok - I found out what it was ... damn Merb!!

      do_sqlite3-0.9.7

  After I removed this gem (which is a dependency installed by Merb)
  everything went back to working right.  I reinstalled the gem, and I
  get the same error again.  So there's something going on between Rails
  and this particular gem - although I'm not smart enough to figure out
  what, nor have time to.

  So if you're running into the same issue I would just take out that
  gem - but it probably means you can't use SQLite with your Merb
  applications.  I have to wonder if this was done on purpose as a sort
  of sabotage, since there is this religious war going on with Merb and
  Rails.

  On Nov 22, 7:48 am, ncancelliere [EMAIL PROTECTED] wrote:

   I've updated to the Rails 2.2 gem and now I can't run Rails because I
   get an error it cannot find SQLite3.  I was running just fine under
   2.1.2 with SQlite3.  I'm on a Mac OS X 10.5 (Leopard) system.

gem list rails

   rails (2.2.2, 2.1.2, 2.0.2)
   rails-app-installer (0.2.0)

gem list sqlite

   sqlite3-ruby (1.2.4)

which sqlite3

   /usr/bin/sqlite3

   I know SQLite is installed and working because I can go into it from
   the command line.  For some reason though Rails is not able to find
   it.  Any ideas on how to fix this?  (I've already tried reinstalling
   sqlite3-ruby - sudo gem install sqlite3-ruby, but that doesn't 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Updating select attributes on a profile page

2008-11-24 Thread Thorsten Müller

I use some code like this:

  attr_accessor :new_password

  validates_presence_of :new_password, :on = :create
  validates_length_of :new_password, :minimum = 6, :allow_nil =
true, :allow_blank = true, :unless = :new_password.blank?
  validates_confirmation_of :new_password

  before_save :set_encrypted_password

  def set_encrypted_password
write_attribute(:password, Client.encrypt_password(@new_password))
unless @new_password.nil? || @new_password.blank?
  end

  def self.encrypt_password(password)
Digest::SHA1.hexdigest(something_random_goes_here_#{password})
  end

  def self.authenticate(email, password)
find_by_email_and_password_and_active(email, encrypt_password
(password), true)
  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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: rubygems broken

2008-11-24 Thread expilo

I got 512 MB. Maybe that's too little? I don't think it's the internet
problem. I can download http://gems.rubyforge.org/yaml (27 M) with
wget in 3 min 46 s.

Piotr

On 24 Lis, 16:15, Frederick Cheung [EMAIL PROTECTED] wrote:
 You can download the .gem files yourself and install them. Since
 rubygems 1.2 i've never had any problems, but prior versions were a
 bit problematic (especially on machines with not so much memory)

 Fred

 On Nov 24, 3:04 pm, Bobnation [EMAIL PROTECTED] wrote:

  The only time I've run into anything similar is when my internet has
  either went *kaput* or a firewall setting at work stopped me from
  downloading any gems automatically. I would maybe check there first.

  On Nov 24, 8:15 am, expilo [EMAIL PROTECTED] wrote:

   Hello,

   I have been trying for the last three days on two different debian
   linux platforms x386 and amd64 using different rubygems versions
   1.1.1, 1.2.0 and 1.3.1 to update gems on my system. No way! It only
   says it's  doing a bulk source update, eats all memory and does
   nothing. The longest I was waiting was 10 hours. Surely that's enough
   to update rails installation with dependencies and a couple of other
   gems  on a 1Mb cable line? It seems I'll have to learn to live with
   manual gem downloads. So my question is: how do you live without
   rubygems when you have to? Has anyone any shell scripts that use awk
   or sed, tar and wget? I'm sure they would do a better job. I'm close
   to start writing one but maybe someone already got something like
   this.

   Many thanks for any hints

   Piotr
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: save url parameter in a session

2008-11-24 Thread Frederick Cheung


On 24 Nov 2008, at 18:04, PsionBlue wrote:


 So sessions are not cleared out controller to controller?

Nope. would rather defeat the point of the session


 I found
 another way (prob. a better way), I am using the redirect_to to pass
 the variable. The funny thing about problems is that you need to know
 what the question is before you can solve it I guess... Thanks!

That sounds like a sane way to do it.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: rubygems broken

2008-11-24 Thread Frederick Cheung


On 24 Nov 2008, at 17:33, expilo wrote:


 I got 512 MB. Maybe that's too little? I don't think it's the internet
 problem. I can download http://gems.rubyforge.org/yaml (27 M) with
 wget in 3 min 46 s.

You might well be under pressure with that much ram. I've never had  
that problem since rubygems 1.2

Fred
 Piotr

 On 24 Lis, 16:15, Frederick Cheung [EMAIL PROTECTED] wrote:
 You can download the .gem files yourself and install them. Since
 rubygems 1.2 i've never had any problems, but prior versions were a
 bit problematic (especially on machines with not so much memory)

 Fred

 On Nov 24, 3:04 pm, Bobnation [EMAIL PROTECTED] wrote:

 The only time I've run into anything similar is when my internet has
 either went *kaput* or a firewall setting at work stopped me from
 downloading any gems automatically. I would maybe check there first.

 On Nov 24, 8:15 am, expilo [EMAIL PROTECTED] wrote:

 Hello,

 I have been trying for the last three days on two different debian
 linux platforms x386 and amd64 using different rubygems versions
 1.1.1, 1.2.0 and 1.3.1 to update gems on my system. No way! It only
 says it's  doing a bulk source update, eats all memory and does
 nothing. The longest I was waiting was 10 hours. Surely that's  
 enough
 to update rails installation with dependencies and a couple of  
 other
 gems  on a 1Mb cable line? It seems I'll have to learn to live with
 manual gem downloads. So my question is: how do you live without
 rubygems when you have to? Has anyone any shell scripts that use  
 awk
 or sed, tar and wget? I'm sure they would do a better job. I'm  
 close
 to start writing one but maybe someone already got something like
 this.

 Many thanks for any hints

 Piotr
 


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Strange Issue w/ incorrect controller invocation for nested routes using the same controller name...

2008-11-24 Thread John Trupiano

One is defined like:

class Partner::LoginController  ApplicationController

end

The other is defined like:

class LoginController  ApplicationController

end

Wonder if wrapping the other in module Partner instead of prefixing
the classname with the module would have any effect...

-John

On Nov 24, 1:02 pm, Frederick Cheung [EMAIL PROTECTED]
wrote:
 On 24 Nov 2008, at 17:41, John Trupiano wrote:



  Also, worth noting that the app is running rails 2.1.0 currently.  I
  also had this problem when it was previously running 2.0.2.  Upgrading
  to 2.1.2 is potentially an option, but I'm wary of just trying
  something like that in production when I don't fully understand what
  the problem is, so I'm holding off on that in the meantime.

 Are the classes both named LoginController or is one of them  
 Partner::LoginController ?

 Fred



  -John

  On Nov 24, 12:39 pm, John Trupiano [EMAIL PROTECTED] wrote:
  Hi, I've been battling a very strange and irritating bug for a long
  time now.  The issue is the following:

  I have namespaced my controllers in routes.rb
   * map.resources :login, :collection = [:login, :logout]
   * map.namespace :partner do |p|
        p.resources :login, :collection = [:login, :logout]
      end

  As such, I have two distinct controllers app/controllers/
  login_controller and app/controllers/partner/login_controller.

  I'm running Apache + Passenger 2.0.3.  When apache is freshly
  restarted, requests to /partner/login invoke the proper controller.
  However, after some period of time (or some series of
  actionswhatever it is, I cannot isolate it), the wrong controller
  will be invoked when requesting /partner/login.

  Reaching back into my logs, I see no difference in the logging that
  rails performed.

  *** Log entry before bug starts showing up

  Processing LoginController#index (for xx.xx.xx.xx at 2008-11-24
  10:33:26) [GET]
    Session ID: bb63a070c1fa56a703018fa922359146
    Parameters: {action=index, controller=partner/login}
  Rendering template within layouts/application
  Rendering partner/login/index
  Completed in 0.00188 (531 reqs/sec) | Rendering: 0.00178 (94%) | DB:
  0.00180 (95%) | 200 OK [https://myapp/partner/login]

  *** Log entry after bug has started showing up

  Processing LoginController#index (for xx.xx.xx.xx at 2008-11-24
  12:26:35) [GET]
    Session ID: 5bdeff99bd72fe94cb8b80fd9b6beff6
    Parameters: {action=index, controller=partner/login}
  Rendering template within layouts/static_dashboard
  Rendering login/index
  Completed in 0.00286 (349 reqs/sec) | Rendering: 0.00274 (95%) | DB:
  0.00429 (150%) | 200 OK [https://myapp/partner/login]

  What kills me is that in parameters, the proper controller/action are
  being identified.  But if you look at the succeeding lines, you'll  
  see
  different templates being rendered.

  This has been happening to me for quite a while.  Even prior to  
  moving
  to Passenger quite a while ago, I saw this same bug crop up in
  production when using a mongrel_cluster solution behind Pound.  So  
  I'm
  fairly certain that it's not related to Passenger.  I have not seen  
  it
  arise in my local dev environment (running mongrel).

  I realize this is quite the shot in the dark, but I was curious if
  anyone had any thoughts whatsoever on the source of this problem, or
  if you've encountered anything similar in the past.

  Thanks for any help.

  -John


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to make named_scope aware of association context?

2008-11-24 Thread Frederick Cheung


On 24 Nov 2008, at 18:07, Sven Aas wrote:

 On Mon, Nov 24, 2008 at 12:49 PM, Frederick Cheung [EMAIL PROTECTED] 
  wrote:
 It should do that by itself. You shouldn't need to do anything. Have
 you tried it?

 Fred

 Yes, with code like this:

   named_scope :featured, :joins = :category_assignments,
:conditions =  
 ['category_assignments.featured = ?', true ]

 When I call

   Post.featured

 it works fine. But when I call, category.posts.featured I get

   ActiveRecord::StatementInvalid: SQLite3::SQLException: ambiguous  
 column name: category_assignments.post_id

 because Rails generates this query:

   SELECT posts.* FROM posts
   INNER JOIN category_assignments ON category_assignments.post_id  
 = post.id
   INNER JOIN category_assignments ON posts.id =  
 category_assignments.post_id
   WHERE ((category_assignments.category_id = 1))
   AND   ((category_assignments.featured = 't'))

 As you can see, category_assignments is being joined twice. The  
 named_scope needs to omit the category_assignments join when it gets  
 called on a Category instance.

Oops. I skimmed over the definition of your scope and didn't notice  
that there was a join. I'm going out on a limb here but from inside a  
procedural named scope then if there is a @proxy_owner instance  
variable or if it responds to proxy_owner/proxy_target then it;s an  
association. You could also  check the current scope and see what  
joins are in there.

Fred

 I'm running this on Rails 2.1.1, by the way.

 -Sven

 PS: there was an error in my initial post. I specified
   :conditions = {:category_assignments.featured = true }
 where I ought to have written
   :conditions = ['category_assignments.featured = ?', true]

 


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] return response['location']

2008-11-24 Thread Tony

I'm building an extension to an existing Rails app  but have hit a
problem the developers cannot seem to help me with. From a javascript-
based shadowbox, I post an addition to a RDF triplestore via a proxy
call: with the following in the Rails app ('uri' is the triplestore
address, 'claim' the RDF to be added):

response = Net::HTTP.start(uri.host, uri.port) { |http|
  http.request_post(uri.path, claim, { 'Content-type' = 'text/
turtle' })
}

and want to return the triplestore response to the javascript call. I
was told to use:

send_data(response.body, :type = response['content-type'],
:status = #{response.code})

which half works. But I need to return the response['location'] value
as it contains the uri of the added rdf. But send_data does not seem
to allow the return of the location: is there any way that I can do
this?

Thanks,
Tony.

(Apologies if this is a simple or stupid question: I'm trying to do
this complex (to me) stuff with very little Rails knowledge)

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Date Comparison Problems

2008-11-24 Thread Charley Mills

I've written it as this:


  def expiration_class(document)

delta = Date.today - document.expiration_on

result = case delta
when 720..360: doc_expired_360
when 360..90:  doc_expired_90
when 90..60:   doc_expired_60
when 60..30:   doc_expired_30
when 30..1:doc_expired
else 'doc_current'
end

  end
end


The problem, though, is that it's returning all deltas as doc_current, 
when I know they're not.  Any ideas?


Frederick Cheung wrote:
 I might write this as
 delta = Date.today - document.expiration_on
 case delta
 when 720..360 then 'doc_expired_360'
 when 360..90 then 'doc_expired_90'
 
 etc...
 
 Fred

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: content_for only works inside a yield?

2008-11-24 Thread phil

I've discovered something else.
If you have an rjs template that loads in a partial:

page.replace_html current_channel, :partial = edit_form

and on that page you have:
_edit_form.rhtml:
script type=text/javascript charset=utf-8
function popup() {
alert(way hay);
}
/script

That javascript code is not being rendered. At all (as far as I can
tell)

On Nov 24, 8:44 am, Christopher [EMAIL PROTECTED] wrote:
 I have a similar problem. Upgrading to Rails 2.2.2 from 2.1.2 i've
 lost all view components that are inserted with content_for.

 The content_for call sits inside a view helper, which in turn is used
 inside the view (eghttp://railscasts.com/episodes/30-pretty-page-title).
 If i move the content_for call to inside the view it works fine.

 Any ideas out there?

 On Nov 23, 6:20 pm, phil [EMAIL PROTECTED] wrote:

  I have a partial that has a couple of content_for blocks in it. This
  works fine if I render it from a view that will in itself get rendered
  view yield :layout. But, if I try and render it directly from the
  application layout none of the content_for stuff gets interpreted.

  Two questions
  1) Is this right?
  2) If so, how can I always include a partial inside of my views then?

  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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: return response['location']

2008-11-24 Thread Frederick Cheung



On Nov 24, 6:34 pm, Tony [EMAIL PROTECTED] wrote:
 I'm building an extension to an existing Rails app  but have hit a
 problem the developers cannot seem to help me with. From a javascript-
 based shadowbox, I post an addition to a RDF triplestore via a proxy
 call: with the following in the Rails app ('uri' is the triplestore
 address, 'claim' the RDF to be added):

 response = Net::HTTP.start(uri.host, uri.port) { |http|
   http.request_post(uri.path, claim, { 'Content-type' = 'text/
 turtle' })

 }

 and want to return the triplestore response to the javascript call. I
 was told to use:

 send_data(response.body, :type = response['content-type'],
     :status = #{response.code})

 which half works. But I need to return the response['location'] value
 as it contains the uri of the added rdf. But send_data does not seem
 to allow the return of the location: is there any way that I can do
 this?

Where were you planning on storing it ? It's either the body or a
header of some sort.
For a javascript client you might set
response.headers['X-JSON'] = {:location = foo}.to_json
Prototype response handlers get passed this header (after it has been
parsed into a JS object)

Fred

 Thanks,
 Tony.

 (Apologies if this is a simple or stupid question: I'm trying to do
 this complex (to me) stuff with very little Rails knowledge)
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Strange Issue w/ incorrect controller invocation for nested routes using the same controller name...

2008-11-24 Thread Frederick Cheung


On 24 Nov 2008, at 18:31, John Trupiano wrote:


 One is defined like:

 class Partner::LoginController  ApplicationController

 end

 The other is defined like:

 class LoginController  ApplicationController

 end

 Wonder if wrapping the other in module Partner instead of prefixing
 the classname with the module would have any effect...

I suspect the complexities of how automatic constant loading work  
means that  if Partner::LoginController isn't loaded but  
LoginController is then it would find the wrong one. using  
require_dependency (eg in application.rb) in forcing rails to load  
both controllers might help.

Fred
 -John

 On Nov 24, 1:02 pm, Frederick Cheung [EMAIL PROTECTED]
 wrote:
 On 24 Nov 2008, at 17:41, John Trupiano wrote:



 Also, worth noting that the app is running rails 2.1.0 currently.  I
 also had this problem when it was previously running 2.0.2.   
 Upgrading
 to 2.1.2 is potentially an option, but I'm wary of just trying
 something like that in production when I don't fully understand what
 the problem is, so I'm holding off on that in the meantime.

 Are the classes both named LoginController or is one of them
 Partner::LoginController ?

 Fred



 -John

 On Nov 24, 12:39 pm, John Trupiano [EMAIL PROTECTED] wrote:
 Hi, I've been battling a very strange and irritating bug for a long
 time now.  The issue is the following:

 I have namespaced my controllers in routes.rb
  * map.resources :login, :collection = [:login, :logout]
  * map.namespace :partner do |p|
   p.resources :login, :collection = [:login, :logout]
 end

 As such, I have two distinct controllers app/controllers/
 login_controller and app/controllers/partner/login_controller.

 I'm running Apache + Passenger 2.0.3.  When apache is freshly
 restarted, requests to /partner/login invoke the proper controller.
 However, after some period of time (or some series of
 actionswhatever it is, I cannot isolate it), the wrong  
 controller
 will be invoked when requesting /partner/login.

 Reaching back into my logs, I see no difference in the logging that
 rails performed.

 *** Log entry before bug starts showing up

 Processing LoginController#index (for xx.xx.xx.xx at 2008-11-24
 10:33:26) [GET]
   Session ID: bb63a070c1fa56a703018fa922359146
   Parameters: {action=index, controller=partner/login}
 Rendering template within layouts/application
 Rendering partner/login/index
 Completed in 0.00188 (531 reqs/sec) | Rendering: 0.00178 (94%) |  
 DB:
 0.00180 (95%) | 200 OK [https://myapp/partner/login]

 *** Log entry after bug has started showing up

 Processing LoginController#index (for xx.xx.xx.xx at 2008-11-24
 12:26:35) [GET]
   Session ID: 5bdeff99bd72fe94cb8b80fd9b6beff6
   Parameters: {action=index, controller=partner/login}
 Rendering template within layouts/static_dashboard
 Rendering login/index
 Completed in 0.00286 (349 reqs/sec) | Rendering: 0.00274 (95%) |  
 DB:
 0.00429 (150%) | 200 OK [https://myapp/partner/login]

 What kills me is that in parameters, the proper controller/action  
 are
 being identified.  But if you look at the succeeding lines, you'll
 see
 different templates being rendered.

 This has been happening to me for quite a while.  Even prior to
 moving
 to Passenger quite a while ago, I saw this same bug crop up in
 production when using a mongrel_cluster solution behind Pound.  So
 I'm
 fairly certain that it's not related to Passenger.  I have not seen
 it
 arise in my local dev environment (running mongrel).

 I realize this is quite the shot in the dark, but I was curious if
 anyone had any thoughts whatsoever on the source of this problem,  
 or
 if you've encountered anything similar in the past.

 Thanks for any help.

 -John


 


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Date Comparison Problems

2008-11-24 Thread Frederick Cheung


On 24 Nov 2008, at 18:40, Charley Mills wrote:


 I've written it as this:

 
  def expiration_class(document)

delta = Date.today - document.expiration_on

result = case delta
when 720..360: doc_expired_360
when 360..90:  doc_expired_90
when 90..60:   doc_expired_60
when 60..30:   doc_expired_30
when 30..1:doc_expired
else 'doc_current'
end

  end
 end
 

 The problem, though, is that it's returning all deltas as  
 doc_current,
 when I know they're not.  Any ideas?

because your ranges are back to front. ranges must be  
smallest..largest (check whether you want ... instead of .. i never  
remember which is which)

Fred

 Frederick Cheung wrote:
 I might write this as
 delta = Date.today - document.expiration_on
 case delta
 when 720..360 then 'doc_expired_360'
 when 360..90 then 'doc_expired_90'

 etc...

 Fred

 -- 
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Strange Issue w/ incorrect controller invocation for nested routes using the same controller name...

2008-11-24 Thread John Trupiano

So, to be clear, you're suggesting that I place the following at the
top of my application.rb file?

class ApplicationController  ActionController::Base
  require_dependency 'partner/login_controller'
  require_dependency 'login_controller'

  # ...

end

Should those calls be inside or outside of the ApplicationController?
Also, are the paths correct, or should I fully prefix them with
RAILS_ROOT?

I've never directly invoked require_dependency beforefor what
purposes do you find it useful (aside from a potential solution to my
struggles)?

Thanks so much!

-John

On Nov 24, 1:45 pm, Frederick Cheung [EMAIL PROTECTED]
wrote:
 On 24 Nov 2008, at 18:31, John Trupiano wrote:





  One is defined like:

  class Partner::LoginController  ApplicationController

  end

  The other is defined like:

  class LoginController  ApplicationController

  end

  Wonder if wrapping the other in module Partner instead of prefixing
  the classname with the module would have any effect...

 I suspect the complexities of how automatic constant loading work  
 means that  if Partner::LoginController isn't loaded but  
 LoginController is then it would find the wrong one. using  
 require_dependency (eg in application.rb) in forcing rails to load  
 both controllers might help.

 Fred

  -John

  On Nov 24, 1:02 pm, Frederick Cheung [EMAIL PROTECTED]
  wrote:
  On 24 Nov 2008, at 17:41, John Trupiano wrote:

  Also, worth noting that the app is running rails 2.1.0 currently.  I
  also had this problem when it was previously running 2.0.2.  
  Upgrading
  to 2.1.2 is potentially an option, but I'm wary of just trying
  something like that in production when I don't fully understand what
  the problem is, so I'm holding off on that in the meantime.

  Are the classes both named LoginController or is one of them
  Partner::LoginController ?

  Fred

  -John

  On Nov 24, 12:39 pm, John Trupiano [EMAIL PROTECTED] wrote:
  Hi, I've been battling a very strange and irritating bug for a long
  time now.  The issue is the following:

  I have namespaced my controllers in routes.rb
   * map.resources :login, :collection = [:login, :logout]
   * map.namespace :partner do |p|
        p.resources :login, :collection = [:login, :logout]
      end

  As such, I have two distinct controllers app/controllers/
  login_controller and app/controllers/partner/login_controller.

  I'm running Apache + Passenger 2.0.3.  When apache is freshly
  restarted, requests to /partner/login invoke the proper controller.
  However, after some period of time (or some series of
  actionswhatever it is, I cannot isolate it), the wrong  
  controller
  will be invoked when requesting /partner/login.

  Reaching back into my logs, I see no difference in the logging that
  rails performed.

  *** Log entry before bug starts showing up

  Processing LoginController#index (for xx.xx.xx.xx at 2008-11-24
  10:33:26) [GET]
    Session ID: bb63a070c1fa56a703018fa922359146
    Parameters: {action=index, controller=partner/login}
  Rendering template within layouts/application
  Rendering partner/login/index
  Completed in 0.00188 (531 reqs/sec) | Rendering: 0.00178 (94%) |  
  DB:
  0.00180 (95%) | 200 OK [https://myapp/partner/login]

  *** Log entry after bug has started showing up

  Processing LoginController#index (for xx.xx.xx.xx at 2008-11-24
  12:26:35) [GET]
    Session ID: 5bdeff99bd72fe94cb8b80fd9b6beff6
    Parameters: {action=index, controller=partner/login}
  Rendering template within layouts/static_dashboard
  Rendering login/index
  Completed in 0.00286 (349 reqs/sec) | Rendering: 0.00274 (95%) |  
  DB:
  0.00429 (150%) | 200 OK [https://myapp/partner/login]

  What kills me is that in parameters, the proper controller/action  
  are
  being identified.  But if you look at the succeeding lines, you'll
  see
  different templates being rendered.

  This has been happening to me for quite a while.  Even prior to
  moving
  to Passenger quite a while ago, I saw this same bug crop up in
  production when using a mongrel_cluster solution behind Pound.  So
  I'm
  fairly certain that it's not related to Passenger.  I have not seen
  it
  arise in my local dev environment (running mongrel).

  I realize this is quite the shot in the dark, but I was curious if
  anyone had any thoughts whatsoever on the source of this problem,  
  or
  if you've encountered anything similar in the past.

  Thanks for any help.

  -John


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] undefined symbol: rb_str_set_len

2008-11-24 Thread Rene Cienfuegos

I recently downgraded from ruby 1.8.7-p72 to 1.8.6-p287 and now whenever
i try to access the mysqldatabase my rails server (WEBrick) crashes with
the following error:

ruby: symbol lookup error:
/usr/lib/ruby/site_ruby/1.8/i686-linux/mysql.so: undefined symbol:
rb_str_set_len

i first thought it was some sort of linking error or something due to
the downgrade, but i just made another DB from scratch and keep getting
the same result.

Does anyone have an idea of what could be the problem or how to fix it?

-R
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Nested and non-nested resources, and admin restrictions

2008-11-24 Thread Nick Hoffman

This is a fairly long question, but it's a common one that applies to  
a lot of applications. Here goes!

Many apps have/want a setup similar to this:

1) ModelA has many ModelBs (Eg: User has many Photos).
2) Admins CRUD all photos at /photos and beyond (Eg: /photos/1/edit).
3) Admins CRUD User photos at /user/1/photos and beyond.
4) Users CRUD their photos at /account/photos and beyond.

Some people don't bother with #2, because photos can be CRUDed via #3.  
However, I want #2 because it gives you a higher/broader view of the  
Photos resource.

I'm trying to figure out an efficient, DRY/semi-DRY way of  
implementing this. At the moment:

For #2 above, I've:
1) Restricted PhotosController to admins.
2) Created a Photos resource (map.resources :photos).

For #3 above, I've:
1) Nested a Photos resource within the Users resource:
  map.resources :users, :has_many = :photos

For #4 above, I've:
1) Created Account::PhotosController, which restricts photos to the  
current user (account).
2) Nested Account::PhotosController within the Account singleton  
resource:
  map.resource :account do |account|
account.resources :photos, :controller = 'account/photos'
  end

Everything but #3 works perfectly. /user/1/photos calls  
PhotosController#index , which finds all photos, rather than finding  
only photos belonging to user 1.

I've come up with a few solutions, but don't feel that any of them are  
ideal.

Solution #1:
Create a whole new controller, which finds photos within the specified  
user. However, this would duplicate 95% of PropertiesController, which  
is pretty dirty.

Solution #2:
Create a method in PhotosController that abstracts the finding of  
photos. However, this feels wrong because it's mixing functionality  
between two different resources (photos vs user-photos).
See http://pastie.org/pastes/322733

Solution #3:
Create a new controller which inherits from PhotosController, and add  
a bit of logic to PhotosController to prevent it from finding photos  
when they've already been found.
See http://pastie.org/322734

Solution #4:
Use the resource_controller plugin. However, I find that r_c limits  
what I can do in some controller actions. For example, r_c only  
provides customisable failure scenarios for #create, #update and  
#destroy, while I need to customise every action's failure scenario.

So, what do you guys think of those solutions, and are there any other  
solutions that are more ideal?

Cheers,
Nick

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: strange behavior of expire_fragment

2008-11-24 Thread Richard Schneeman

Ar Chron wrote:
 Have you determined what
 
%r{.*}
 
 evaluates to in the context of your Sweeper?

%r{.*} will delete absoloutly everything in my cache, i think i found my 
error after reading this forum thread 
http://www.ruby-forum.com/topic/145163#643061 .

In my controller i had:
phrase_sweeper :phrase_sweeper, :only = [:create, :update, :destroy]

when i was actually using an action called :rank_up, for some reason i 
just assumed if i was updating a model, the :update action would cover 
it, although i wasn't using :update in my controller. I've yet to try 
the changes, but i'll let you know the outcome. The confusing part was 
that the sweeper gets called no mater what, but the expire_fragment only 
works on the specified actions.
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: undefined symbol: rb_str_set_len

2008-11-24 Thread Frederick Cheung

Probably because your mysql gem has been built against 1.8.6. I'd try  
reinstalling the mysql gem.

Fred

Sent from my iPhone

On 24 Nov 2008, at 19:18, Rene Cienfuegos [EMAIL PROTECTED] 
  wrote:


 I recently downgraded from ruby 1.8.7-p72 to 1.8.6-p287 and now  
 whenever
 i try to access the mysqldatabase my rails server (WEBrick) crashes  
 with
 the following error:

 ruby: symbol lookup error:
 /usr/lib/ruby/site_ruby/1.8/i686-linux/mysql.so: undefined symbol:
 rb_str_set_len

 i first thought it was some sort of linking error or something due to
 the downgrade, but i just made another DB from scratch and keep  
 getting
 the same result.

 Does anyone have an idea of what could be the problem or how to fix  
 it?

 -R
 -- 
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Strange Issue w/ incorrect controller invocation for nested routes using the same controller name...

2008-11-24 Thread Frederick Cheung



Sent from my iPhone

On 24 Nov 2008, at 19:06, John Trupiano [EMAIL PROTECTED] wrote:


 So, to be clear, you're suggesting that I place the following at the
 top of my application.rb file?

 class ApplicationController  ActionController::Base
  require_dependency 'partner/login_controller'
  require_dependency 'login_controller'

  # ...

 end

 Should those calls be inside or outside of the ApplicationController?
 Also, are the paths correct, or should I fully prefix them with
 RAILS_ROOT?

Outside the class and you don't need a path or anything
 I've never directly invoked require_dependency beforefor what
 purposes do you find it useful (aside from a potential solution to my
 struggles)?

It's like require but plays nicely with the dependencies system. Use  
it whenever you're requiring something that could be magically loaded  
(models, controllers etc)
 Thanks so much!

 -John

 On Nov 24, 1:45 pm, Frederick Cheung [EMAIL PROTECTED]
 wrote:
 On 24 Nov 2008, at 18:31, John Trupiano wrote:





 One is defined like:

 class Partner::LoginController  ApplicationController

 end

 The other is defined like:

 class LoginController  ApplicationController

 end

 Wonder if wrapping the other in module Partner instead of prefixing
 the classname with the module would have any effect...

 I suspect the complexities of how automatic constant loading work
 means that  if Partner::LoginController isn't loaded but
 LoginController is then it would find the wrong one. using
 require_dependency (eg in application.rb) in forcing rails to load
 both controllers might help.

 Fred

 -John

 On Nov 24, 1:02 pm, Frederick Cheung [EMAIL PROTECTED]
 wrote:
 On 24 Nov 2008, at 17:41, John Trupiano wrote:

 Also, worth noting that the app is running rails 2.1.0  
 currently.  I
 also had this problem when it was previously running 2.0.2.
 Upgrading
 to 2.1.2 is potentially an option, but I'm wary of just trying
 something like that in production when I don't fully understand  
 what
 the problem is, so I'm holding off on that in the meantime.

 Are the classes both named LoginController or is one of them
 Partner::LoginController ?

 Fred

 -John

 On Nov 24, 12:39 pm, John Trupiano [EMAIL PROTECTED] wrote:
 Hi, I've been battling a very strange and irritating bug for a  
 long
 time now.  The issue is the following:

 I have namespaced my controllers in routes.rb
  * map.resources :login, :collection = [:login, :logout]
  * map.namespace :partner do |p|
   p.resources :login, :collection = [:login, :logout]
 end

 As such, I have two distinct controllers app/controllers/
 login_controller and app/controllers/partner/login_controller.

 I'm running Apache + Passenger 2.0.3.  When apache is freshly
 restarted, requests to /partner/login invoke the proper  
 controller.
 However, after some period of time (or some series of
 actionswhatever it is, I cannot isolate it), the wrong
 controller
 will be invoked when requesting /partner/login.

 Reaching back into my logs, I see no difference in the logging  
 that
 rails performed.

 *** Log entry before bug starts showing up

 Processing LoginController#index (for xx.xx.xx.xx at 2008-11-24
 10:33:26) [GET]
   Session ID: bb63a070c1fa56a703018fa922359146
   Parameters: {action=index, controller=partner/login}
 Rendering template within layouts/application
 Rendering partner/login/index
 Completed in 0.00188 (531 reqs/sec) | Rendering: 0.00178 (94%) |
 DB:
 0.00180 (95%) | 200 OK [https://myapp/partner/login]

 *** Log entry after bug has started showing up

 Processing LoginController#index (for xx.xx.xx.xx at 2008-11-24
 12:26:35) [GET]
   Session ID: 5bdeff99bd72fe94cb8b80fd9b6beff6
   Parameters: {action=index, controller=partner/login}
 Rendering template within layouts/static_dashboard
 Rendering login/index
 Completed in 0.00286 (349 reqs/sec) | Rendering: 0.00274 (95%) |
 DB:
 0.00429 (150%) | 200 OK [https://myapp/partner/login]

 What kills me is that in parameters, the proper controller/action
 are
 being identified.  But if you look at the succeeding lines,  
 you'll
 see
 different templates being rendered.

 This has been happening to me for quite a while.  Even prior to
 moving
 to Passenger quite a while ago, I saw this same bug crop up in
 production when using a mongrel_cluster solution behind Pound.   
 So
 I'm
 fairly certain that it's not related to Passenger.  I have not  
 seen
 it
 arise in my local dev environment (running mongrel).

 I realize this is quite the shot in the dark, but I was curious  
 if
 anyone had any thoughts whatsoever on the source of this problem,
 or
 if you've encountered anything similar in the past.

 Thanks for any help.

 -John


 

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

[Rails] Namespacing conventions

2008-11-24 Thread Nick Hoffman

I compared the output from ``rake routes'' for each solution below,  
and they both produce the exact same routes. Is one solution preferred  
over the over?

# Solution #1:
map.resource  :account do |account|
   account.resources :properties, :controller = 'account/properties'
   account.resources :photos, :controller = 'account/photos'
end

# Solution #2:
map.resource  :account
map.namespace :account do |account|
   account.resources :photos
   account.resources :properties
end

Cheers,
Nick

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Subdomain fu woes

2008-11-24 Thread Philip Hallstrom


On Nov 24, 2008, at 6:22 AM, [EMAIL PROTECTED] wrote:


 I'm using subdomain_fu successfully and generating subdomain routes
 like this:

 rotues.rb:
 map.city_root '',:controller = 'cities', :action =
 'index', :conditions = { :subdomain = /.+/ }

 using it in a view:
 %= link_to city.name, city_root_path(:subdomain = city.subdomain)%

 that works well, now I can't figure out how to generate a nested route
 with subdomain,
 i.e. miami.site.com/users/1

 trying any combination of the form user_path(@user,:subdomain =
 city.subdomain) does nothing excepnt append a parameter at the end of
 the url like this:

 site.com/users/1?subdomain=miami

In addition to the fix you found, you may also want to check out this  
patch.

http://rails.lighthouseapp.com/projects/8994/tickets/1115-path-to-extend-named-routes-support-for-an-objects-to_params-method

I wrote that because of a recent site I built with 18 subdomains and  
not wanting to write out all those links by hand.

In your case above you could define a to_params method on User to  
return the hash (including the subdomain) and then just do  
user_path(@user) and it will do the right thing.

Anyway, see the ticket for more info.

-philip

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: strange behavior of expire_fragment

2008-11-24 Thread Ar Chron

Richard Schneeman wrote:
 The confusing part was 
 that the sweeper gets called no mater what, but the expire_fragment only 
 works on the specified actions.

I actually gave up on the sweepers in my app, as they were far too 
general, and expired more than was necessary in some cases, and given 
the filters and sorting that can be done, it's all fragment caching.

Now the models decide which of their own fragments to expire (via 
Rails.cache.delete) depending on what was changed.
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: strange behavior of expire_fragment

2008-11-24 Thread Richard Schneeman

 Now the models decide which of their own fragments to expire (via 
 Rails.cache.delete) depending on what was changed.

Sounds interesting do you have a code snippet or tutorial you can point 
me to, before i get too entrenched in this sweeper mess??
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Hidden file

2008-11-24 Thread Rong

Yes, but I keep deleting the folder and it keeps coming back. It's
empty but it keeps re-appearing.

On Nov 24, 3:30 am, Rick [EMAIL PROTECTED] wrote:
 That's where gems will be installed if  you run a gem install ...
 command and you don't have permission to create files in the default
 gem directory.  If you run sudo gem install ... the gems will be
 installed in the default location.

 Rick

 On Nov 23, 7:58 pm, Rong [EMAIL PROTECTED] wrote:

  Does anyone know the purpose of a hidden file called .gems in my
  home folder on os x?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: MySQL

2008-11-24 Thread Mr. Watson

Everything is working correct. I can log into MySQL. Ruby on Rails is
up on running on the localhost. It created the database for me. But
every time I use the rake db:migrate command it gives me the error.

rake aborted!
Access denied for user 'root'@'localhost' (using password: YES)

(See full trace by running task with --trace)

I ran it with trace and got the following message:
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!

(And many system files afterwards)

Any ideas?


On Nov 24, 11:13 am, Hassan Schroeder [EMAIL PROTECTED]
wrote:
 On Mon, Nov 24, 2008 at 8:25 AM,Mr.Watson[EMAIL PROTECTED] wrote:

  I did that and it worked. But I type in the rake db:migrate command
  and it tells me  Access denied for user '[EMAIL PROTECTED]' 

 You need to configure config/database.yml with the appropriate
 access information (username, password, etc.) for your DB.

 --
 Hassan Schroeder  [EMAIL PROTECTED]
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: MySQL

2008-11-24 Thread Mr. Watson

It is acting like it is working. For example, I typed in rake
db:migrate and it created the databse and the post.rb file. But it is
still showing the error: Access denied for user
'root'@'localhost' (using password: YES)

On Nov 24, 2:20 pm, Mr. Watson [EMAIL PROTECTED] wrote:
 Everything is working correct. I can log into MySQL. Ruby on Rails is
 up on running on the localhost. It created the database for me. But
 every time I use the rake db:migrate command it gives me the error.

 rake aborted!
 Access denied for user 'root'@'localhost' (using password: YES)

 (See full trace by running task with --trace)

 I ran it with trace and got the following message:
 ** Invoke db:migrate (first_time)
 ** Invoke environment (first_time)
 ** Execute environment
 ** Execute db:migrate
 rake aborted!

 (And many system files afterwards)

 Any ideas?

 On Nov 24, 11:13 am, Hassan Schroeder [EMAIL PROTECTED]
 wrote:

  On Mon, Nov 24, 2008 at 8:25 AM,Mr.Watson[EMAIL PROTECTED] wrote:

   I did that and it worked. But I type in the rake db:migrate command
   and it tells me  Access denied for user '[EMAIL PROTECTED]' 

  You need to configure config/database.yml with the appropriate
  access information (username, password, etc.) for your DB.

  --
  Hassan Schroeder  [EMAIL PROTECTED]
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: MySQL

2008-11-24 Thread Hassan Schroeder

On Mon, Nov 24, 2008 at 12:20 PM, Mr. Watson [EMAIL PROTECTED] wrote:

 Everything is working correct. I can log into MySQL. Ruby on Rails is
 up on running on the localhost. It created the database for me. But
 every time I use the rake db:migrate command it gives me the error.

 rake aborted!
 Access denied for user 'root'@'localhost' (using password: YES)

That's saying that the password for root in database.yml is wrong;
are you saying that it's not? You can log in *using the exact same
information* as you've got in database.yml?

-- 
Hassan Schroeder  [EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: MySQL

2008-11-24 Thread Mr. Watson

Also, in SQL, I type mysql -u root -p=password (as I configured the
database.yml file) and it gives me the same error.

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using
password: YES)

On Nov 24, 2:20 pm, Mr. Watson [EMAIL PROTECTED] wrote:
 Everything is working correct. I can log into MySQL. Ruby on Rails is
 up on running on the localhost. It created the database for me. But
 every time I use the rake db:migrate command it gives me the error.

 rake aborted!
 Access denied for user 'root'@'localhost' (using password: YES)

 (See full trace by running task with --trace)

 I ran it with trace and got the following message:
 ** Invoke db:migrate (first_time)
 ** Invoke environment (first_time)
 ** Execute environment
 ** Execute db:migrate
 rake aborted!

 (And many system files afterwards)

 Any ideas?

 On Nov 24, 11:13 am, Hassan Schroeder [EMAIL PROTECTED]
 wrote:

  On Mon, Nov 24, 2008 at 8:25 AM,Mr.Watson[EMAIL PROTECTED] wrote:

   I did that and it worked. But I type in the rake db:migrate command
   and it tells me  Access denied for user '[EMAIL PROTECTED]' 

  You need to configure config/database.yml with the appropriate
  access information (username, password, etc.) for your DB.

  --
  Hassan Schroeder  [EMAIL PROTECTED]
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: :has_many :through form validation messages problem

2008-11-24 Thread Greg Hauptmann

I was just wondering where the associated_records comes from?  Just
tried your idea but got a:

   undefined local variable or method `associated_records'

Where did you put valid_associated_records? exactly?   Is it just a
method you call from within the model's validate function?

thanks

On Thu, Jul 31, 2008 at 3:50 AM, walker [EMAIL PROTECTED] wrote:

 I had to come up with a hack to get around this (duplicate and generic
 validation error messages). I also wanted to include my specific error
 messages from the child models. Basically, this is my custom
 validator:

  #custom validator so i can make error messages appear the way i want
  #(instead of validates_associated)
  def valid_associated_records?
associated_records.each do |ar|
  if(!ar.nil?  !ar.valid?)
#get rid of the default error message
errors.delete(:attribute_name)

#take specific error messages from children, put them in this
 model's errors
ar.errors.each do |attr, msg|
  errors.add(attr, msg)
end
  end
end
  end

 The tricky part is errors.delete--the errors class doesn't expose a
 delete method, even though it uses a hash as an underlying data type,
 which does have a delete method. So I created a file (lib/
 error_delete.rb) with this in it to extend the Errors class and expose
 it:

 module ActiveRecord
  class Errors
# add function to delete a particular error message
def delete(key)
  @errors.delete(key.to_s)
end
  end
 end

 Put in require 'error_delete' at the top of the file where you call
 the delete function. Hope that's helpful!


 On Jul 29, 9:49 pm, Usman Akram [EMAIL PROTECTED]
 wrote:
  I was wondering the same thing...Have you found a solution?

 No man just waiting for some help. its not a bug the validation takes
 place only once I just dont know how to switch off the invalid record
 notification. u can see the custom validation messages are being sent
 out but also along with the invalid child validation . if you find
 something kindly inform
 Regards!
 Usman

 --
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: MySQL

2008-11-24 Thread Mr. Watson

Database.yml file:

# SQLite version 3.x
#   gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
  adapter: mysql
  database: depot_development
  username: root
  password: root
  host: localhost

# Warning: The database defined as test will be erased and
# re-generated from your development database when you run rake.
# Do not set this db to the same as development or production.
test:
  adapter: mysql
  database: depot_test
  username: root
  password: root
  host: localhost

production:
  adapter: mysql
  database: depot_production
  username: root
  password: root
  host: localhost

I am typing in mysql -u root -p=root

On Nov 24, 2:35 pm, Hassan Schroeder [EMAIL PROTECTED]
wrote:
 On Mon, Nov 24, 2008 at 12:20 PM, Mr. Watson [EMAIL PROTECTED] wrote:

  Everything is working correct. I can log into MySQL. Ruby on Rails is
  up on running on the localhost. It created the database for me. But
  every time I use the rake db:migrate command it gives me the error.

  rake aborted!
  Access denied for user 'root'@'localhost' (using password: YES)

 That's saying that the password for root in database.yml is wrong;
 are you saying that it's not? You can log in *using the exact same
 information* as you've got in database.yml?

 --
 Hassan Schroeder  [EMAIL PROTECTED]
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: MySQL

2008-11-24 Thread Mr. Watson

On the end, I put the  there. It is not in the yml file.

On Nov 24, 2:41 pm, Mr. Watson [EMAIL PROTECTED] wrote:
 Database.yml file:

 # SQLite version 3.x
 #   gem install sqlite3-ruby (not necessary on OS X Leopard)
 development:
   adapter: mysql
   database: depot_development
   username: root
   password: root
   host: localhost

 # Warning: The database defined as test will be erased and
 # re-generated from your development database when you run rake.
 # Do not set this db to the same as development or production.
 test:
   adapter: mysql
   database: depot_test
   username: root
   password: root
   host: localhost

 production:
   adapter: mysql
   database: depot_production
   username: root
   password: root
   host: localhost

 I am typing in mysql -u root -p=root

 On Nov 24, 2:35 pm, Hassan Schroeder [EMAIL PROTECTED]
 wrote:

  On Mon, Nov 24, 2008 at 12:20 PM, Mr. Watson [EMAIL PROTECTED] wrote:

   Everything is working correct. I can log into MySQL. Ruby on Rails is
   up on running on the localhost. It created the database for me. But
   every time I use the rake db:migrate command it gives me the error.

   rake aborted!
   Access denied for user 'root'@'localhost' (using password: YES)

  That's saying that the password for root in database.yml is wrong;
  are you saying that it's not? You can log in *using the exact same
  information* as you've got in database.yml?

  --
  Hassan Schroeder  [EMAIL PROTECTED]
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: MySQL

2008-11-24 Thread Mr. Watson

I can log in with mysql -u root but it still gives me an error when
using rake db:migrate

On Nov 24, 2:35 pm, Hassan Schroeder [EMAIL PROTECTED]
wrote:
 On Mon, Nov 24, 2008 at 12:20 PM, Mr. Watson [EMAIL PROTECTED] wrote:

  Everything is working correct. I can log into MySQL. Ruby on Rails is
  up on running on the localhost. It created the database for me. But
  every time I use the rake db:migrate command it gives me the error.

  rake aborted!
  Access denied for user 'root'@'localhost' (using password: YES)

 That's saying that the password for root in database.yml is wrong;
 are you saying that it's not? You can log in *using the exact same
 information* as you've got in database.yml?

 --
 Hassan Schroeder  [EMAIL PROTECTED]
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: MySQL

2008-11-24 Thread Mr. Watson

It still doesn't work typing mysql -u root -proot

On Nov 24, 2:46 pm, Mr. Watson [EMAIL PROTECTED] wrote:
 I can log in with mysql -u root but it still gives me an error when
 using rake db:migrate

 On Nov 24, 2:35 pm, Hassan Schroeder [EMAIL PROTECTED]
 wrote:

  On Mon, Nov 24, 2008 at 12:20 PM, Mr. Watson [EMAIL PROTECTED] wrote:

   Everything is working correct. I can log into MySQL. Ruby on Rails is
   up on running on the localhost. It created the database for me. But
   every time I use the rake db:migrate command it gives me the error.

   rake aborted!
   Access denied for user 'root'@'localhost' (using password: YES)

  That's saying that the password for root in database.yml is wrong;
  are you saying that it's not? You can log in *using the exact same
  information* as you've got in database.yml?

  --
  Hassan Schroeder  [EMAIL PROTECTED]
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: MySQL

2008-11-24 Thread Hassan Schroeder

On Mon, Nov 24, 2008 at 12:48 PM, Mr. Watson [EMAIL PROTECTED] wrote:

 It still doesn't work typing mysql -u root -proot

Then your database.yml is *WRONG*.

If you can login to MySQL with only `mysql -u root` it means you have
*NO* password set for the root account. Which is bad. You should fix
that ASAP and then correct your database.yml.

-- 
Hassan Schroeder  [EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: MySQL

2008-11-24 Thread Mr. Watson

It still doesn't work typing mysql -u root -proot

On Nov 24, 2:40 pm, Hassan Schroeder [EMAIL PROTECTED]
wrote:
 On Mon, Nov 24, 2008 at 12:37 PM, Mr. Watson [EMAIL PROTECTED] wrote:

  Also, in SQL, I type mysql -u root -p=password (as I configured the
  database.yml file) and it gives me the same error.

 That should be -ppassword -- no =, and no space separating the -p
 from the actual password.

 --
 Hassan Schroeder  [EMAIL PROTECTED]
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Namespacing conventions

2008-11-24 Thread Freddy Andersen

I guess you have the answer in your question... You don't need the
controller part so it would look like this:

map.resource  :account do |account|
   account.resources :properties
   account.resources :photos
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Updating select attributes on a profile page

2008-11-24 Thread Bobnation

I did a really kludgy fix last night using attr_protected, and I like
certain aspects of your idea as well. If I find some time tonight I'll
probably take a look at the code again to try and work out a more
beautiful option for myself. :)

Thanks for your help!

On Nov 24, 11:53 am, Thorsten Müller [EMAIL PROTECTED] wrote:
 I use some code like this:

   attr_accessor :new_password

   validates_presence_of :new_password, :on = :create
   validates_length_of :new_password, :minimum = 6, :allow_nil =
 true, :allow_blank = true, :unless = :new_password.blank?
   validates_confirmation_of :new_password

   before_save :set_encrypted_password

   def set_encrypted_password
     write_attribute(:password, Client.encrypt_password(@new_password))
 unless @new_password.nil? || @new_password.blank?
   end

   def self.encrypt_password(password)
     Digest::SHA1.hexdigest(something_random_goes_here_#{password})
   end

   def self.authenticate(email, password)
     find_by_email_and_password_and_active(email, encrypt_password
 (password), true)
   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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: should this work? - validates_inclusion_of :start_date, :in = (Time.now.to_date - 100.years)..(Time.now.to_date + 100.years)

2008-11-24 Thread Rick

Hello Greg,

So here it is.  After a couple of mail exchanges with Fred, I need to
tell you that I was wrong from the start.  Your initial code as given,

validates_inclusion_of :start_date, :in =
  (Time.now.to_date - 100.years)..(Time.now.to_date + 100.years)

will work in the case where :start_date is the name of one of your
records fields and is a member of the Time class.

Sorry if my confused meander wasted too much of your time.

Thanks for your help Fred.

Rick

On Nov 22, 1:52 pm, Greg Hauptmann [EMAIL PROTECTED]
wrote:
 thanks - I'm specifically looking at Dates so I might stick with the
 below that seems to be working fine...

     errors.add('start_date', 'is not in Date format') if
 !start_date.kind_of?(Date)

 cheers

 On Sat, Nov 22, 2008 at 9:30 PM, Rick [EMAIL PROTECTED] wrote:

  Greg - you might take a look at time_with_zone.rb in ActiveSupport -
  I'm looking at 2.2.0 but I know it's in 2.1.2 as well.

  a = Time.now
  a.is_a?(Time) = true
  a = My name is Fred
  a.is_a?(Time) = false

  Maybe closer to what you need?

  Rick

  On Nov 22, 1:04 am, Rick [EMAIL PROTECTED] wrote:
  Right, but back to your initial question, I don't think my initial
  answer was even close to the mark.

  I believe the problem you're having is that the validates_inclusion is
  looking for an enumeration hanging off the :in.  i.e.  [1,2,3,4,5] or
  1..5 will work but (My Name Is Frank)..(Your Name Is Louie) somehow
  doesn't look right, does it?

  You're doing :in = (Sun, 22 Nov 1908)..(Sun, 22 Nov 2108)
  which just isn't going to happen.  Try converting to Julian days, that
  way you'll be bounded with two positive integers.

  Rick

  On Nov 21, 8:08 pm, Greg Hauptmann [EMAIL PROTECTED]
  wrote:

   I've actually run with the following:

     def validate
       errors.add('start_date', 'is not in Date format') if
   !start_date.kind_of?(Date)
       errors.add('end_date', 'is not in Date format') if 
   !end_date.kind_of?(Date)
     end

   Its seems that the Rails controller tries to convert it to Date and
   either succeeds or fails (without throwing an exception).  So I just
   test to see at the subsequent validate stage whether there is a Date
   object or not

   On Sat, Nov 22, 2008 at 5:22 AM, Rick [EMAIL PROTECTED] wrote:

Greg,

validates_inclusion_of is looking for :in to be an enumeration.  In a
simple case (one day granularity) you're asking for a list that's
365.25 * 200 = 73050 items long.

My guess is it's a good thing it didn't work ;-)

Maybe you want to go for a min/max check here.

Rick

On Nov 20, 11:22 am, Greg Hauptmann [EMAIL PROTECTED]
wrote:
wondering if should this work? - validates_inclusion_of :start_date,
:in = (Time.now.to_date - 100.years)..(Time.now.to_date + 100.years)
 (doesn't seem to for me)

i.e. should I be able to validates_inclusion_of to do date 
validation.


  class GraphOptions  ActiveRecord::BaseWithoutTable
    column :start_date, :date
    validates_inclusion_of :start_date, :in = (Time.now.to_date -
100.years)..(Time.now.to_date + 100.years)
  end


tks
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: MySQL

2008-11-24 Thread Mr. Watson

I got a password now. (I downloaded MySQL 6.0 to get it) The rake
db:migrate command is still not working.

On Nov 24, 2:40 pm, Hassan Schroeder [EMAIL PROTECTED]
wrote:
 On Mon, Nov 24, 2008 at 12:37 PM, Mr. Watson [EMAIL PROTECTED] wrote:

  Also, in SQL, I type mysql -u root -p=password (as I configured the
  database.yml file) and it gives me the same error.

 That should be -ppassword -- no =, and no space separating the -p
 from the actual password.

 --
 Hassan Schroeder  [EMAIL PROTECTED]
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: MySQL

2008-11-24 Thread Mr. Watson

It works. You were right. I made a mistake on the yml.

On Nov 24, 3:10 pm, Mr. Watson [EMAIL PROTECTED] wrote:
 I got a password now. (I downloaded MySQL 6.0 to get it) The rake
 db:migrate command is still not working.

 On Nov 24, 2:40 pm, Hassan Schroeder [EMAIL PROTECTED]
 wrote:

  On Mon, Nov 24, 2008 at 12:37 PM, Mr. Watson [EMAIL PROTECTED] wrote:

   Also, in SQL, I type mysql -u root -p=password (as I configured the
   database.yml file) and it gives me the same error.

  That should be -ppassword -- no =, and no space separating the -p
  from the actual password.

  --
  Hassan Schroeder  [EMAIL PROTECTED]
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: does anyone know whether ActiveRecord has supported connection pool?

2008-11-24 Thread Jonathan Rochkind

It has to do with multiple connections to one database.

It has, however, always been possible to have some models living in one 
database, and others living in others, if that's what you want. 
Relationships accross databases don't always work perfectly, if you're 
trying to do fancy things. (Like, pre-loading a relationship accross 
databases).

For using multiple databases in your app, see:

http://wiki.rubyonrails.org/rails/pages/HowtoUseMultipleDatabases

Incidentally, even pre Rails 2.2, I have had success using multiple 
connections to a single db in different threads, using the mysql gem 
adapter. Now I wonder if the mysql gem adapter is actually non-blocking 
though, or if my different threads were still blocking on db access.

Jonathan

boblu wrote:
 Can anybody tell me about this?
 Does this connection pool have something to do with multiple
 database connection?
 Or it is only for concurrent access with one database?

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: An RSpec Model Example

2008-11-24 Thread torm3nt

Just curious if anyone found this helpful?

On Nov 14, 9:22 am, torm3nt [EMAIL PROTECTED] wrote:
 Testing is currently my hobby, it's just something I LOVE doing,
 watching all the code be tested automagically.. I dunno, kinda helps
 me sleep at night. A lot of people (including myself) seem to have
 trouble with testing, so I thought I'd write up an article detailing a
 simple model. You can checkout the article below, and please feel free
 to comment or offer your own advice!

 http://www.kirkbushell.com/articles/rspec-model-example

 Kirk
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] attachment_fu - uploading from different models in the same action

2008-11-24 Thread shagymoe

Hi,

I've got a situation where I want to upload a zip file and an image
from the same form.  Each attachment is a different model. So, here's
what I've got.


Models:

class LogoImage  ActiveRecord::Base
  belongs_to :company

  has_attachment :max_size = 1.megabytes,
 :storage = :s3,
 :s3_config_path = (RAILS_ROOT + '/config/
companies_s3.yml'),
 :content_type = :image,
 :thumbnails = { :large = '96x96' ,
  :medium = '64x64' ,
  :small = '48x48'},
 :processor = :MiniMagick

  validates_as_attachment
end

class ZipFile  ActiveRecord::Base
  belongs_to :apps

  has_attachment :max_size = 1.megabytes,
 :storage = :s3,
 :s3_config_path = (RAILS_ROOT + '/config/
apps_s3.yml'),
 :content_type = :image,
 :thumbnails = { :large = '96x96' ,
  :medium = '64x64' ,
  :small = '48x48'},
 :processor = :MiniMagick

  validates_as_attachment
end

class App  ActiveRecord::Base
  has_one :zip_file
  belongs_to :companies
end

class Company  ActiveRecord::Base
  has_one :logo_image
  has_one :app
end


 View #
%= error_messages_for :company %
%= error_messages_for :app %
%= error_messages_for :zip_file %
%= error_messages_for :logo_image %

% form_tag({:action = new_app}, { :multipart=true }) do -%
  %= file_field_tag zip_file %
  %= file_field_tag logo_image %
% end %

### CONTROLLER 
def new_app
  @app = params[:id].nil? ? App.new : App.find(params[:id])
  @company = Company.new(params[:company])
  @zip_file = ZipFile.new(:uploaded_data = params[:zip_file])
  @logo_image = LogoImage.new(:uploaded_data = params[:logo_image])

  if request.post?
@app.attributes = params[:app]
@company.attributes = params[:company]

App.transaction do
  @company.save!

  @logo_image.company_id = @company.id
  @logo_image.save!

  @app.company_id = @company.id
  @app.save!

  @zip_file.app_id = @app.id
  @zip_file.save!
end
  end
end

## config files ##
apps_s3.yml

development:
bucket_name: apps_development
access_key_id: id
secret_access_key: key

companies_3.yml

development:
bucket_name: companies_development
access_key_id: id
secret_access_key: key

3

Of course, there is a lot more info in there, but I tried to condense
it.  The issue is that everything is getting saved, but the logo image
is getting saved in the same bucket as the zip file.  It seems that
attachment_fu is just taking the bucket from the last attachment saved
and putting them both there. Either this is a bug or I'm doing
something wrong or it isn't meant to do what I'm trying to do.

Any ideas?

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] mislav-will_paginate complicated SQL made up from params

2008-11-24 Thread John Small

I have a search form which sends a set of params to a controller. The
params are unpacked and SQL generated which is then fed into
(1)
MyModel.paginate_by_sql [sql],:page = params[:page], :per_page = 30

Which all works fine and lovely, on the first page..

The links in each of the visible page buttons simply point to
/controller/search_action?page=2 or 3  so on. All the params used to
create the sql are missing. So when the call comes in for the next page,
only clean no selection sql is generated and I get the second (or third
 etc) page of the entire data set, not the sub-set selected by the
form.

When I do this by
(2)
AnOtherModel.find_with_ferret  params[:search_for],
{:page=params[:page], :per_page = 30}

then search_for=something is added to the params list attached to the
pagination links, so I can page back and forth in a search result set.
So that works OK.

How do I get the params for my query in (1) to be added to the
pagination links so I get the params back to redo the query for the next
page?
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: rubygems broken

2008-11-24 Thread expilo

Oh! What joy! It does work indeed! Many thanks for the solution.

P.

On 24 Lis, 22:34, Brian Hogan [EMAIL PROTECTED] wrote:
 It's a problem with your particular version of Rubygems. I just worked
 around it here. The amount of RAM you need for the bulk update depends
 on the amount of Gems you have installed.

 The easy solution is to upgrade to 1.3.0 or higher where bulk updating
 no longer happens.

 wgethttp://rubyforge.org/frs/download.php/43984/rubygems-update-1.3.0.gem
 sudo gem install rubygems-update-1.3.0.gem
 sudo update_rubygems

 Then to make sure you have the latest...

 sudo gem update --system

 On Mon, Nov 24, 2008 at 3:27 PM, expilo [EMAIL PROTECTED] wrote:

  What on earth could it be? Ruby version? Mine is 1.8.7 (2008-08-11
  patchlevel 72) [x86_64-linux] I tried again latest (1.3.1) version and
  it behaves  the same. It slowly eats memory until about 80% and then
  starts swapping heavily. Maybe that's simply the way it's supposed to
  be nowadays and one can only add more RAM? Can you say how much RAM
  you got?

  Piotr

  On 24 Lis, 19:00, Frederick Cheung [EMAIL PROTECTED] wrote:
  On 24 Nov 2008, at 17:54, expilo wrote:

   So what  RAM size would you recommend? If 512MB is too little another
   tool is really needed, at least for those on low memory VPSs.

  I don't honestly know, but what I was trying to say is that that
  problem has gone away since rubygems 1.2. If you've still got that
  problem then it's something else

   Piotr

   On 24 Lis, 18:41, Frederick Cheung [EMAIL PROTECTED] wrote:
   On 24 Nov 2008, at 17:33, expilo wrote:

   I got 512 MB. Maybe that's too little? I don't think it's the
   internet
   problem. I can downloadhttp://gems.rubyforge.org/yaml(27M) with
   wget in 3 min 46 s.

   You might well be under pressure with that much ram. I've never had
   that problem since rubygems 1.2

   Fred

   Piotr

   On 24 Lis, 16:15, Frederick Cheung [EMAIL PROTECTED]
   wrote:
   You can download the .gem files yourself and install them. Since
   rubygems 1.2 i've never had any problems, but prior versions were a
   bit problematic (especially on machines with not so much memory)

   Fred

   On Nov 24, 3:04 pm, Bobnation [EMAIL PROTECTED] wrote:

   The only time I've run into anything similar is when my internet
   has
   either went *kaput* or a firewall setting at work stopped me from
   downloading any gems automatically. I would maybe check there
   first.

   On Nov 24, 8:15 am, expilo [EMAIL PROTECTED] wrote:

   Hello,

   I have been trying for the last three days on two different
   debian
   linux platforms x386 and amd64 using different rubygems versions
   1.1.1, 1.2.0 and 1.3.1 to update gems on my system. No way! It
   only
   says it's  doing a bulk source update, eats all memory and does
   nothing. The longest I was waiting was 10 hours. Surely that's
   enough
   to update rails installation with dependencies and a couple of
   other
   gems  on a 1Mb cable line? It seems I'll have to learn to live
   with
   manual gem downloads. So my question is: how do you live without
   rubygems when you have to? Has anyone any shell scripts that use
   awk
   or sed, tar and wget? I'm sure they would do a better job. I'm
   close
   to start writing one but maybe someone already got something like
   this.

   Many thanks for any hints

   Piotr
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Actionwebservice as a SOAP client to .NET services.

2008-11-24 Thread Tim Uckun

 You probably want SOAP4R. See http://rubyforge.org/projects/soap4r/
 and also my tutorial at 
 http://markthomas.org/2007/09/12/getting-started-with-soap4r

Thanks. I have written a stand alone ruby script that fetches the data
I want. The next step is to see if I can make it work in rails.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



  1   2   >