[Rails] Re: including a blank in a dropdown

2009-05-12 Thread Vinay Seshadri
I think..
REPLACE
unless params[:location][:id].blank?
#set location

WITH
unless params[:location].blank?
#set location

Remember, the location id that the user will submit IF he uses the form will
still be in params[:location][:id]. So if you're doing a find in there using
the ID then you can access it by using params[:location][:id].

A better check would be to check the commit message that gets passed when
the user submits the form. In this case, if your form submit button says
Go, then

unless params[:commit] == Go
#set location

On Tue, May 12, 2009 at 12:07 AM, bingo bob 
rails-mailing-l...@andreas-s.net wrote:


 Ah. Maybe this is the problem.

 The form is on the index page.
 The form is not submitted when the user goes to this index page.

 The form is only submitted when they click the go button.

 How do I handle that?

 Vinay Seshadri wrote:
  Now because the parameters are empty, the form really isnt working. do
  take
  a look at the API. Implement form_tag or form_for for your needs and
  make it
  work. Check if you've got the parameters. And go from there...

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

 



-- 
In Sport We Trust !!!

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



[Rails] Where to put additional code for model.

2009-05-12 Thread Jim Burgess

Hi,
I have written a method to map three 'virtual' fields in my form to one
'proper' field in my model.
It looks like this:

class Class
  def map_three_fields(var1, var2, var3)
string_val = ...do stuff...
   self.class_eval string_val
  end
end

At the moment it is sitting at the top of my model, but the method is
quite long and this looks a bit ugly / cluttered.

Is there anywhere else I can put this code?
And if so, will it work out of the box or do I need to add a require
somewhere or alter any configuration files.

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

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



[Rails] Re: nested hash and nil question

2009-05-12 Thread Ryan Waldron
What value should 'zip' contain if postal_code_number doesn't exist (or any
of the keys above it)?

If one of the keys in that long nasty chain are nil, you're going to get an
exception, but if you know an acceptable default value in case you can't
eval the whole expression, rescue the exception and return what you want.

If you want it to be an empty string, for instance, you could do:

zip =
placemark['address_details']['country']['administrative_area']['locality']['postal_code']['postal_code_number']
rescue ''


On Tue, May 12, 2009 at 12:53 AM, scott scot...@gmail.com wrote:


 i need to pull out some specific values from a nested hash, but nils
 are driving me crazy. in the following example, if address_details,
 country, administrative_area, locality OR postal_code are nil i get
 The error occurred while evaluating nil.[]

 zip = placemark['address_details']['country']['administrative_area']
 ['locality']['postal_code']['postal_code_number']

 i tried

 unless placemark['address_details']['country']['administrative_area']
 ['locality']['postal_code']['postal_code_number'].nil?

 but if anything above postal_code_number is nil i still get the error.
 i could check each level but that is really ugly.

 is there a easy way to check if postal_code_number exists?


 


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



[Rails] Re: how to get the multiple selected data from select_tag.

2009-05-12 Thread nishi

Hi Fred,
thx for ur resp.

but i hv one more ques.
here we r using the

   options_from_collection_for_select
(Attribute.find_all_by_attributetype(cons)

I need a solution where  we will get the data from model not directly
by collection_select
please give me sm idea, i need it as soon as possible.


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



[Rails] Re: Nested attributes, fields_for

2009-05-12 Thread Kostas


Hello,

Thanks for your answer. I ended up doing the workaround, as my patch
was failing miserably in the general case :)
Yes, you're right, the workaround is inelegant to say the least. I'll
be checking up your code as well, see what you did, maybe come up with
some idea.

Thanks again!

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



[Rails] rails 2.3.2 is not generating environment.rb properly

2009-05-12 Thread Aashish Kiran

problem: rails 2.3.2 is not generating
config.action_controller.session_store = :active_record_store in
environment.rb

this is the code in   environment.rb
---

# Be sure to restart your server when you modify this file

# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION

# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')

Rails::Initializer.run do |config|
  # Settings in config/environments/* take precedence over those
specified here.
  # Application configuration should go into files in
config/initializers
  # -- all .rb files in that directory are automatically loaded.

  # Add additional load paths for your own custom dirs
  # config.load_paths += %W( #{RAILS_ROOT}/extras )

  # Specify gems that this application depends on and have them
installed with rake gems:install
  # config.gem bj
  # config.gem hpricot, :version = '0.6', :source =
http://code.whytheluckystiff.net;
  # config.gem sqlite3-ruby, :lib = sqlite3
  # config.gem aws-s3, :lib = aws/s3

  # Only load the plugins named here, in the order given (default is
alphabetical).
  # :all can be used as a placeholder for all plugins not explicitly
named
  # config.plugins = [ :exception_notification, :ssl_requirement, :all ]

  # Skip frameworks you're not going to use. To use Rails without a
database,
  # you must remove the Active Record framework.
  # config.frameworks -= [ :active_record, :active_resource,
:action_mailer ]

  # Activate observers that should always be running
  # config.active_record.observers = :cacher, :garbage_collector,
:forum_observer

  # Set Time.zone default to the specified zone and make Active Record
auto-convert to this zone.
  # Run rake -D time for a list of tasks for finding time zone names.
  config.time_zone = 'UTC'

  # The default locale is :en and all translations from
config/locales/*.rb,yml are auto loaded.
  # config.i18n.load_path += Dir[Rails.root.join('my', 'locales',
'*.{rb,yml}')]
  # config.i18n.default_locale = :de
end

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

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



[Rails] Identify dynamic name using Scrubyt

2009-05-12 Thread Saurabh Peshkar

Hi All,

I'm trying to execute the following code.

url = https://xxx.com;(some url)
ebay_data = Scrubyt::Extractor.define :agent = :firefox  do
 fetch(url)
 fill_textfield field name, value
 record //tab...@id='header'] do
   name //inp...@class='req']
 end
end

Code executes properly for static name of textfield

But the url which i'm trying to fetch is having dynamic name so when i
try to run the code it gives me error:

  Unable to locate element, using :name, 
(Watir::Exception::UnknownObjectException)

Every time the name changes on refresh. Please suggest me how should I
fill the text field of a url with dynamic text_field name. (Using
Scrubyt)

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

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



[Rails] What's New In Rails?

2009-05-12 Thread Salil Gaikwad

Hi All,
I want to know what is the new in Ruby On Rails i.e. what is the
latest version of the Rails? what's new in it ? updates for the New Gems
and Plugins.
anything related to ruby actually i want to update myself on technology.


Thanks  Regards
Salil Gaikwad






If you're not up-to-date with technology trends, it's better to keep
your mouth shut and let people think you're a genius than to open your
mouth and remove all doubt.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Deleting Sessions with no logout

2009-05-12 Thread Colin Law
I think you may find there is no reliable way of achieving this, there was a
significant thread on this issue a little while ago.
What is the unwanted behaviour that you are seeing? Perhaps there is a
better solution.
Colin

2009/5/11 Shandy Nantz rails-mailing-l...@andreas-s.net


 I tried this:

 In View:

 % func =  remote_function( :url = { :action = 'set_sessions_nil'} )
 -%
 body onunload = %= func %
 .
 /body

 In Controller:

 def set_sessions_nil
  session[:user] = nil
  session[:arranger] = nill
 end

 Pretty straight forward, but after I open and close a few windows my
 server running the localhost dies - it just sits there and does nothing,
 so don't try that a home.

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

 


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



[Rails] Re: Simple Post to CookBook

2009-05-12 Thread Colin Law
I woudl suggest first you need to determine whether the problem is in the C#
code or in the server.
Have you looked in the rails log to see if the request being received by the
server is as you expect?
If so does that url work if you enter it from a browser?
Colin

2009/5/11 Ridha Bagana rails-mailing-l...@andreas-s.net


 I am trying to post from C# to a simple Ruby on Rails page.
 I am using the cookbook of Ruby on rails. So I just want to create a new
 category from C#
 I do it like this in c#

 string url = http://localhost:3000/categories.xml;;
 oPostData = ASCIIEncoding.UTF8.GetBytes(category=TestCat);
 ie.Navigate2(ref oURL, ref oEmpty, ref oEmpty, ref oPostData, ref
 oHeader);


 I get this

 NoMethodError in CategoriesController#create
 undefined method `stringify_keys!' for TestCat:String
 RAILS_ROOT: C:/InstantRails/rails_apps/cookbook


 C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:2111:in
 `attributes='

 C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1926:in
 `initialize'
 app/controllers/categories_controller.rb:43:in `new'
 app/controllers/categories_controller.rb:43:in `create'

 Request
 Parameters:

 {format=xml,
  category=TestCat}

 Show session dump

 ---
 :csrf_id: 5dc6b3aa43b099703c798ea053ad9ebb
 flash: !map:ActionController::Flash::FlashHash {}

 Response
 Headers:
 {cookie=[],
  Cache-Control=no-cache}



 I think I am not supposed to pass the parameter that way. Can anybody
 show me where and how I am supposed to post on this. Any help will be
 appreciated .
 Thanks in advance
 --
 Posted via http://www.ruby-forum.com/.

 


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



[Rails] Yet Another Time Zone Question

2009-05-12 Thread Randall

Seems like there should be an easy solution to this problem, yet I
can't seem to find one.

Here is the issue:
How do you assign a time zone to a Time object that results from a
parsed date/time string?

Example:
- I receive a date time string from a date picker widget that does not
include time zone info (i.e. Mon May 11 18:24:37 2009).
- Time zone for this date is known and may be different than what's
local to the user
- date/time is stored in the DB as unix time (i.e. 1242075962)
- time zone is stored in the DB in tz format i(i.e. 'America/
New_York')
- I would like to be able to take a given date with its known time
zone and calculate the equivalent unix time value.

 now = Time.now
= Mon May 11 18:24:37 -0400 2009
 now.to_i
= 1242080677


 parsed = DateTime.parse(Mon May 11 18:24:37 2009)
= Mon, 11 May 2009 18:24:37 +
 parsed.to_time
= Mon May 11 18:24:37 UTC 2009
 parsed.to_time.to_i
= 1242066277
 Time.at 1242066277
= Mon May 11 14:24:37 -0400 2009

It seems there should be a way to append the time zone to the string
before it is parsed or to associate the parsed time with a time zone
(without converting the time to the zone), however I can't seem to
find an answer.

Any help would be greatly appreciated

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



[Rails] Migrate VB.NET to ROR

2009-05-12 Thread GeoKid

Hi,
We are currently hitting among ourselves to see if there is migration
tool/process in place to convert a VB.NET code base into ROR.
Essentially, our product is currently a desktop version and one of the
options for us is to adapt ASP.NET.  However, we wanted something more
elegant - ROR.  Any thoughts,  rants, suggestions would be GREATLY
appreciated. Thanks in advance.

Peace,

Shree

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



[Rails] Re: rails 2.3.2 is not generating environment.rb properly

2009-05-12 Thread Frederick Cheung



On May 12, 8:22 am, Aashish Kiran rails-mailing-l...@andreas-s.net
wrote:
 problem: rails 2.3.2 is not generating
 config.action_controller.session_store = :active_record_store in
 environment.rb

I think that's in an initializer these days.

Fred
 this is the code in   environment.rb
 ---

 # Be sure to restart your server when you modify this file

 # Specifies gem version of Rails to use when vendor/rails is not present
 RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION

 # Bootstrap the Rails environment, frameworks, and default configuration
 require File.join(File.dirname(__FILE__), 'boot')

 Rails::Initializer.run do |config|
   # Settings in config/environments/* take precedence over those
 specified here.
   # Application configuration should go into files in
 config/initializers
   # -- all .rb files in that directory are automatically loaded.

   # Add additional load paths for your own custom dirs
   # config.load_paths += %W( #{RAILS_ROOT}/extras )

   # Specify gems that this application depends on and have them
 installed with rake gems:install
   # config.gem bj
   # config.gem hpricot, :version = '0.6', :source =
 http://code.whytheluckystiff.net;
   # config.gem sqlite3-ruby, :lib = sqlite3
   # config.gem aws-s3, :lib = aws/s3

   # Only load the plugins named here, in the order given (default is
 alphabetical).
   # :all can be used as a placeholder for all plugins not explicitly
 named
   # config.plugins = [ :exception_notification, :ssl_requirement, :all ]

   # Skip frameworks you're not going to use. To use Rails without a
 database,
   # you must remove the Active Record framework.
   # config.frameworks -= [ :active_record, :active_resource,
 :action_mailer ]

   # Activate observers that should always be running
   # config.active_record.observers = :cacher, :garbage_collector,
 :forum_observer

   # Set Time.zone default to the specified zone and make Active Record
 auto-convert to this zone.
   # Run rake -D time for a list of tasks for finding time zone names.
   config.time_zone = 'UTC'

   # The default locale is :en and all translations from
 config/locales/*.rb,yml are auto loaded.
   # config.i18n.load_path += Dir[Rails.root.join('my', 'locales',
 '*.{rb,yml}')]
   # config.i18n.default_locale = :de
 end

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



[Rails] Re: Where to put additional code for model.

2009-05-12 Thread 7stud --

Jim Burgess wrote:
 Hi,
 I have written a method to map three 'virtual' fields in my form to one
 'proper' field in my model.
 It looks like this:
 
 class Class
   def map_three_fields(var1, var2, var3)
 string_val = ...do stuff...
self.class_eval string_val
   end
 end
 
 At the moment it is sitting at the top of my model, but the method is
 quite long and this looks a bit ugly / cluttered.
 
 Is there anywhere else I can put this code?


In my opinion (backed by zero experience), models are serfs, and 
controllers are the aristocrats that command the serfs to do various 
chores.  So if you think a controller is going to get its hands dirty 
doing the work of a serf, well...you better think again.

Of course you could create another model--one not hooked up to a 
database--that has a class method that you could call like this:

Utilities.map_three_fields()

And no, you wouldn't need a require.




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

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



[Rails] Re: Flash notices are not accessible on next request

2009-05-12 Thread Luke Pearce

Tom Hoen wrote:

 Luke - Thanks for responding. I use embedded Active Scaffolds, so need 
 to have render component installed. I commented out a line that called 
 flash.sweep:

Thanks very much for this Tom.  We're using ActiveScaffold too so this 
is really useful; let us know if you get a reply about it.


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

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



[Rails] Re: Migrate VB.NET to ROR

2009-05-12 Thread Fidel Viegas

On Tue, May 12, 2009 at 6:17 AM, GeoKid srikanth.pa...@gmail.com wrote:

 Hi,
 We are currently hitting among ourselves to see if there is migration
 tool/process in place to convert a VB.NET code base into ROR.
 Essentially, our product is currently a desktop version and one of the
 options for us is to adapt ASP.NET.  However, we wanted something more
 elegant - ROR.  Any thoughts,  rants, suggestions would be GREATLY
 appreciated. Thanks in advance.

Hi Shrikanth,

The answer to this is no, because RoR uses a convention that you must
follow in order to develop web apps, whereas in your VB.NET
application you follow your own convention. The only way to convert
your VB.NET project to RoR is to rewrite your code by hand using RoR's
conventions. There isn't really I straight way of converting VB.NET
projects to RoR, because you can have two developers develop two
VB.NET applications using two different conventions.

What you could probably do (I have never done this) is try to map RoR
models to your legacy database.

Maybe others with more experience can give you some hints as well.

Good luck!

Fidel.

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



[Rails] Re: Where to put additional code for model.

2009-05-12 Thread Colin Law
2009/5/12 Jim Burgess rails-mailing-l...@andreas-s.net


 Hi,
 I have written a method to map three 'virtual' fields in my form to one
 'proper' field in my model.
 It looks like this:

 class Class
  def map_three_fields(var1, var2, var3)
string_val = ...do stuff...
   self.class_eval string_val
  end
 end

 At the moment it is sitting at the top of my model, but the method is
 quite long and this looks a bit ugly / cluttered.


You could put it down the end of the model, it should be in the private
section anyway, presumably.
If it is that ugly/cluttered you could refactor it.
Colin



 Is there anywhere else I can put this code?
 And if so, will it work out of the box or do I need to add a require
 somewhere or alter any configuration files.

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

 


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



[Rails] STI good or bad for my problem?

2009-05-12 Thread fredd

Hi. I am currently developing a small course system for student and
teachers. The system is divided in sections and sections have many
messages, comments, documents and schedules. Pretty easy to set up
using ROR, just add some belongs_to and has_many relations. But
everything becomes much more complicated when the section items
(message, comment and so on...) all has comments. And they can also be
a favorite to a users favorite list and much more. Basically all the
items has some shared generic stuff that I just don't want to copy
around. Let's check my rest routes so everyone understands better:

map.resources :sections do |sections|
sections.resources :messages
sections.resources :documents
sections.resources :schedules
end

map.resources :items do |item|
item.resources :comments
item.resources :favorites
end

I would basically want to have a generic resource (Item) that takes
care of comments, favorites and so on. And that is what my question is
all about. Is it a good way to inherit from a base class called Items
using STI? Or could I solve this problem some other way? If I don't
have a base class I would have to nest the comment resources to each
of the items and that's not a good solution either.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: rails 2.3.2 is not generating environment.rb properly

2009-05-12 Thread Aashish Kiran

Frederick Cheung wrote:
 On May 12, 8:22�am, Aashish Kiran rails-mailing-l...@andreas-s.net
 wrote:
 problem: rails 2.3.2 is not generating
 config.action_controller.session_store = :active_record_store in
 environment.rb

 I think that's in an initializer these days.
 
 Fred



thank  u, it solved my problem
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Where to put additional code for model.

2009-05-12 Thread Michael Schuerig

On Tuesday 12 May 2009, Jim Burgess wrote:
 Hi,
 I have written a method to map three 'virtual' fields in my form to
 one 'proper' field in my model.
 It looks like this:

 class Class
   def map_three_fields(var1, var2, var3)
 string_val = ...do stuff...
self.class_eval string_val
   end
 end

I hope you know what you're doing. What if one of the strings is

%x{echo gotcha}

or worse?

 At the moment it is sitting at the top of my model, but the method is
 quite long and this looks a bit ugly / cluttered.

Then move it down to the bottom, or if you want to hide it even more, 
put it in a module:

class MyModel  ActiveRecord::Base
  include ComplicatedStuff
  ...
end

 And if so, will it work out of the box or do I need to add a
 require somewhere or alter any configuration files.

As long as it is in one of the usual directories, i.e. app/models, 
lib, the module will be found automatically.

Michael

-- 
Michael Schuerig
mailto:mich...@schuerig.de
http://www.schuerig.de/michael/


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



[Rails] Re: Where to put additional code for model.

2009-05-12 Thread Jim Burgess

Hi,

Thanks very much for the replies.
I will follow Michael's advice and stick it in a module.

 I hope you know what you're doing.

Probably nowhere near as much as I should

 What if one of the strings is
 %x{echo gotcha}
 or worse?

It's a date input which is mapped.
In the model the field is :dob and is a string.
In the form this is split into :dob_day, :dob_month, :dob_year

Using the method I wrote (currently) in my model I can them write:
map_three_fields :dob_day, :dob_month, :dob_year

and they are returned as a string containing a date in the form of 
dd-mm- (including hyphens).

In the form the maximum length of dob_day and dob_year are 2 characters. 
The maximum length of dob_year is 4 characters.

Therefore (I hope) it is not possible to enter %x{echo gotcha}.

Now the question to make you slap your hand on your head and look at the 
ceiling:
What would this do, anyway?

Do you have any comments, ideas, criticism about doing things this way?

I found relatively little on the inputing of dates in forms using Rails 
online (date select is genuinely rubbish) and the form should also run 
without javascript. Therefore I put this method together myself and 
would be very grateful if anyone could point out if there are any 
massive security exploits that I have overlooked.

If it would help I can post the full code of what I have done.

Thanks very much in advance.


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

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



[Rails] Re: STI good or bad for my problem?

2009-05-12 Thread David Bourguignon
Hello,
STI seems not suitable, I would call that abuse, unless you have almost
everything common between yout different tables.

But you can use o polymorphic relation for comment, and extract the common
behaviour in a plugin (something like acts_as_commentable)

Look here : hhttp://
guides.rails.info/association_basics.html#polymorphic-associations

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



[Rails] 2.3 Nested Model Forms; build new without updating existing

2009-05-12 Thread Guitaronin

I'm trying to build something similar to a Facebook messaging app, in
which the view displays all the messages for a particular thread, with
a form box for replying at the bottom of the thread.

The problem is that using fields_for generates form fields for each
existing record, and for one new record. In this case, there is no
need to edit existing messages - just a need to add new messages.

Does anybody know how to do this? Code is below.

Models:
class MessageThread  ActiveRecord::Base
  has_many :messages
  accepts_nested_attributes_for :messages, :allow_destroy = true
end

class Message  ActiveRecord::Base
  belongs_to :message_threads
end

View (show.html.erb)

  % @message_thread.messages.each do |message| %
  %= message.message %
  % end %

% form_for @message_thread do |thread_form| -%
  % thread_form.fields_for :messages do |message| %
  %= message.label :message %
  %= message.text_field :message %
  % end %

  %= submit_tag 'Send Message' %
  % end -%

Thanks.

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



[Rails] RJS Error: TypeError: while using active scaffold

2009-05-12 Thread Chirag Shah

Hi,

I get an unexpected error because i havent do any chnages in any
javascript files, after installing active scaffold. Before 1-2 days my
application is working fine but from yesterday i got the error for RJS
as below while i tried for show action.

RJS error:
TypeError: $(#console__private_messages-messages) is null

$(#console__private_messages-messages).html(\n  \n\n  \n\n  \n\n);

And while i tried to remove the record then i got error as per below..


RJS error:
TypeError: $(#console__complaints-list-27-row) is null


$('console__complaints-destroy-27-link').action_link.close_previous_adapter();
$(#console__complaints-list-27-row).remove();
ActiveScaffold.reload_if_empty('console__complaints-tbody','/console/complaints/update_table?page=1');
ActiveScaffold.stripe('console__complaints-tbody');
ActiveScaffold.decrement_record_count('console__complaints-active-scaffold');
$(#console__complaints-messages).html(\n  \n\n  \n\n  \n\n);

There is no errors in the log.  Any Suggestions?
Need more info?

Thanks,
Chirag Shah
Software Engineer
http://blogofchirag.blogspot.com/
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Where to put additional code for model.

2009-05-12 Thread Michael Schuerig

On Tuesday 12 May 2009, Jim Burgess wrote:
 Hi,

 Thanks very much for the replies.
 I will follow Michael's advice and stick it in a module.

  I hope you know what you're doing.

 Probably nowhere near as much as I should

  What if one of the strings is
  %x{echo gotcha}
  or worse?

 It's a date input which is mapped.
 In the model the field is :dob and is a string.
 In the form this is split into :dob_day, :dob_month, :dob_year

 Using the method I wrote (currently) in my model I can them write:
 map_three_fields :dob_day, :dob_month, :dob_year

 and they are returned as a string containing a date in the form of
 dd-mm- (including hyphens).

Why? IMHO, the best you can do is have a look at how date_select works, 
you'll notice that it already does what you're trying to do. For the 
long story see the code in date_helper.rb and date_helper_test.rb 
somewhere in ActionView and 
Activerecord::Base#assign_multiparameter_attributes. For the short 
story, name your fields

dob(1i), dob(2i), and dob(3i) and have ActiveRecord put together these 
parts.

 In the form the maximum length of dob_day and dob_year are 2
 characters. The maximum length of dob_year is 4 characters.

 Therefore (I hope) it is not possible to enter %x{echo gotcha}.

Careful! It may not be possible to enter anything exceeding the max 
length in the average browser, but that doesn't stop anyone to submit 
requests to your app with other tools.


 Now the question to make you slap your hand on your head and look at
 the ceiling:
 What would this do, anyway?

%x{echo gotcha} is another way of writing `echo gotcha`. Each of these 
executes the given command(s) with the right of the current user. It's 
like that you wouldn't enter cd $HOME; rm -rf by yourself, so you'd 
better not give someone else an opportunity to enter %x{cd $HOME, rm -
rf} for you.


 Do you have any comments, ideas, criticism about doing things this
 way?

 I found relatively little on the inputing of dates in forms using
 Rails online (date select is genuinely rubbish) and the form should
 also run without javascript. Therefore I put this method together
 myself and would be very grateful if anyone could point out if there
 are any massive security exploits that I have overlooked.

Passing arbitrary, user-provided strings to eval or class_eval *is* a 
huge security hole.

Michael

-- 
Michael Schuerig
mailto:mich...@schuerig.de
http://www.schuerig.de/michael/


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



[Rails] belong to and search

2009-05-12 Thread Anthony Ward

Hi,

I'm trying to understand belongs_to and has_many etc... I understand the
relationship but I'm trying to figure how this can help me

for example I have two tables
i have 2 tables called mothers and another called childrens
in this childrens model i have this

###Childrens model
belongs_to: mother
..
..


now in the
children controller
I want to retrive the mother name currently I'm doing this way

def index ##show all the childrens and their mother's name
  @childrens = Childrens.find(
 :all,
 :select=mothers.name AS mother_name, childrens.* ,
 :join=LEFT JOIN mothers ON mothers.id = childrens.mother_id
  )
end

I was just curious because of the belongs_to I can skip this left join
on tables
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: STI good or bad for my problem?

2009-05-12 Thread fredd

Yes, I was almost thinking that my self. Thanks for clarifying that.
What I now is trying to do is to have a generic model called Item that
relates to the different items through a itemable interface
(belongs_to :itemable, polymorphic = true). And then the Item model
belongs to the Section. What do you think of that?

On 12 Maj, 11:59, David Bourguignon tal.bourguig...@gmail.com wrote:
 Hello,
 STI seems not suitable, I would call that abuse, unless you have almost
 everything common between yout different tables.

 But you can use o polymorphic relation for comment, and extract the common
 behaviour in a plugin (something like acts_as_commentable)

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



[Rails] Re: belong to and search

2009-05-12 Thread Colin Law
If you have set up the associations (belongs_to and has_many) then if you
have a Child object child you can just say child.mother to get the mother.
Similarly if you have a mother object you can say mother.children to get the
children.  It is all done by magic.
Colin

2009/5/12 Anthony Ward rails-mailing-l...@andreas-s.net


 Hi,

 I'm trying to understand belongs_to and has_many etc... I understand the
 relationship but I'm trying to figure how this can help me

 for example I have two tables
 i have 2 tables called mothers and another called childrens
 in this childrens model i have this

 ###Childrens model
 belongs_to: mother
 ..
 ..

 
 now in the
 children controller
 I want to retrive the mother name currently I'm doing this way

 def index ##show all the childrens and their mother's name
  @childrens = Childrens.find(
 :all,
 :select=mothers.name AS mother_name, childrens.* ,
 :join=LEFT JOIN mothers ON mothers.id = childrens.mother_id
  )
 end

 I was just curious because of the belongs_to I can skip this left join
 on tables
 --
 Posted via http://www.ruby-forum.com/.

 


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



[Rails] Re: Where to put additional code for model.

2009-05-12 Thread Jim Burgess

Hi Michael,
Thanks for the reply.

 dd-mm- (including hyphens).
 Why? IMHO, the best you can do is have a look at how date_select works,
 you'll notice that it already does what you're trying to do. 

But isn't date_select really feeble?
For example it is very easy to make the whole application crash by 
giving date_select false input (eg. enetering 31st February with no 
year. http://www.ruby-forum.com/topic/183310)

 Careful! It may not be possible to enter anything exceeding the max
 length in the average browser, but that doesn't stop anyone to submit
 requests to your app with other tools.

Good point.

 %x{echo gotcha} is another way of writing `echo gotcha`. Each of these
 executes the given command(s) with the right of the current user. It's
 like that you wouldn't enter cd $HOME; rm -rf by yourself, so you'd
 better not give someone else an opportunity to enter %x{cd $HOME, rm -
 rf} for you.

Even better point.

 Passing arbitrary, user-provided strings to eval or class_eval *is* a
 huge security hole.

You're right.
I did have everything working without using eval.
The method with eval was just intended to make everything that bit 
neater.
Would it then be sufficient to check the user generated input for 
numericality (ie. enduse that the user has only entered numbers as they 
are supposed to) and only carry out eval in this case, or would that 
make no difference?


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

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



[Rails] Re: including a blank in a dropdown

2009-05-12 Thread bingo bob


Vinay - you nailed it. Many thanks.

I ended up with my controller like this

#===

class WelcomeController  ApplicationController
  def index

# finding all the locations for the drop down
@locations = Location.all


  if params[:commit] == go  params[:location][:id].to_i = 1
# location is set AND it's not a blank location id so find the 
teachers in the location
@location = Location.find(params[:location][:id])
@teachers = @location.teachers
  else
# no form submitted so find just find all teachers
@teachers = Teacher.all
  end

  end


end

#=

Here's my view code..


% title Welcome %
p
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat
nulla pariatur. Excepteur sint occaecat cupidatat non proident,
sunt in culpa qui officia deserunt mollit anim id est laborum.
/p

hr

% form_tag do %

  %= select(location, id, Location.all.collect {|l| [ l.name, l.id 
]}, {:include_blank = true}) %
  %= submit_tag go %

% end -%

hr

% if @teachers %
  % for teacher in @teachers %
%= link_to [teacher.first_name + ' ' + teacher.last_name], teacher 
%br
%= teacher.email %br
Location: %= teacher.location.name %br
Languages:
% for language in teacher.languages %
%= language.name %
% end %
hr
  % end %
% end %

#

Works great.

I'm interested to see any critique of this code? all comments 
appreciated.
Is there a better way to handle the   params[:location][:id].to_i = 1 
it's the way I thought to do it?

Many thanks to all for the comments here - very useful.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: belong to and search

2009-05-12 Thread Anthony Ward

Hi

thanks works like a charm!

but i'm just curious performance wise
when I look at mongrel it seems that there are two queries
first the children.all()
then for each record it does a new query for mother get name...

now is that as quick compare to juts one query with a left join and get 
all the data in children().


Colin Law wrote:
 If you have set up the associations (belongs_to and has_many) then if 
 you
 have a Child object child you can just say child.mother to get the 
 mother.
 Similarly if you have a mother object you can say mother.children to get 
 the
 children.  It is all done by magic.
 Colin
 
 2009/5/12 Anthony Ward rails-mailing-l...@andreas-s.net

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

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



[Rails] Re: invoke a controller def from view without clicking any l

2009-05-12 Thread Mukund

Use prototype functions to handle the onload events.  It is better
than plugging in onload code into your HTML tags.   Look at the online
documentation for examples.   You can use either the dom:loaded event
or the window:onload event.



On May 11, 1:50 pm, Sijo Kg rails-mailing-l...@andreas-s.net wrote:
 Hi
    In my partial I tried like
 div idgraph_div onload=somescript();
 /div

    But this onload not working Since I tried with an alert first Could
 you please tell how can I do this?

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



[Rails] Re: belong to and search

2009-05-12 Thread Colin Law
2009/5/12 Anthony Ward rails-mailing-l...@andreas-s.net


 Hi

 thanks works like a charm!

 but i'm just curious performance wise
 when I look at mongrel it seems that there are two queries
 first the children.all()
 then for each record it does a new query for mother get name...

 now is that as quick compare to juts one query with a left join and get
 all the data in children().


If you know you are going to be accessing the associated objects use
:include in the find to tell Rails to fetch all the data in one query, so
something like
@children = Child.find(:all, :include = :mother)


By the way, I think the class should be Child, the table children and the
controller children_controller.
Rails should know that children is the plural of child.

If you are really building a database of family relationships then you might
want to search for a thread here a few weeks ago about how to organise the
db.  There were some very interesting ideas discussed.

Colin




 Colin Law wrote:
  If you have set up the associations (belongs_to and has_many) then if
  you
  have a Child object child you can just say child.mother to get the
  mother.
  Similarly if you have a mother object you can say mother.children to get
  the
  children.  It is all done by magic.
  Colin
 
  2009/5/12 Anthony Ward rails-mailing-l...@andreas-s.net

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

 


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



[Rails] Re: including a blank in a dropdown

2009-05-12 Thread Vinay Seshadri
# finding all the locations for the drop down
  @locations = Location.all

You dont need this in the controller because you're finding all locations in
the view itself.

Is there a better way to handle the   params[:location][:id].to_i =
1 it's the way I thought to do it?
 !(params[:location][:id].blank?)

or

!(params[:location].blank?)

whatever works for you. You can see i love blank? :)

 Ideally, this whole functionality should go into the model.

Create a teacher.full_name method. Its simple.

On Tue, May 12, 2009 at 4:41 PM, bingo bob rails-mailing-l...@andreas-s.net
 wrote:



 Vinay - you nailed it. Many thanks.

 I ended up with my controller like this

 #===

 class WelcomeController  ApplicationController
  def index

 # finding all the locations for the drop down
@locations = Location.all


  if params[:commit] == go  params[:location][:id].to_i = 1
# location is set AND it's not a blank location id so find the
 teachers in the location
@location = Location.find(params[:location][:id])
@teachers = @location.teachers
  else
# no form submitted so find just find all teachers
@teachers = Teacher.all
  end

  end


 end

 #=

 Here's my view code..


 % title Welcome %
 p
 Lorem ipsum dolor sit amet, consectetur adipisicing elit,
 sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
 Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
 nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
 reprehenderit in voluptate velit esse cillum dolore eu fugiat
 nulla pariatur. Excepteur sint occaecat cupidatat non proident,
 sunt in culpa qui officia deserunt mollit anim id est laborum.
 /p

 hr

 % form_tag do %

  %= select(location, id, Location.all.collect {|l| [ l.name, l.id
 ]}, {:include_blank = true}) %
  %= submit_tag go %

 % end -%

 hr

 % if @teachers %
  % for teacher in @teachers %
%= link_to [teacher.first_name + ' ' + teacher.last_name], teacher
 %br
%= teacher.email %br
Location: %= teacher.location.name %br
Languages:
% for language in teacher.languages %
%= language.name %
% end %
hr
  % end %
 % end %

 #

 Works great.

 I'm interested to see any critique of this code? all comments
 appreciated.
 Is there a better way to handle the   params[:location][:id].to_i = 1
 it's the way I thought to do it?

 Many thanks to all for the comments here - very useful.
 --
 Posted via http://www.ruby-forum.com/.

 



-- 
In Sport We Trust !!!

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



[Rails] [ANN/ADV] The Well-Grounded Rubyist now out in paperback

2009-05-12 Thread David A. Black

Hello all --

I'm delighted to announce that my new book The Well-Grounded Rubyist
is now available in paperback (and still in PDF, of course). It's 
published by Manning, and it's in stock at the publisher[1] and Amazon[2].

TWGR is a reworking, repurposing of my 2006 book Ruby for Rails.
It's not for Rails this time; it's Ruby, specifically Ruby 1.9. It's
got lots of new topics, and expansion and updating of everything.

Enjoy! And let me know how you like it.


David

P.S. The cover was redesigned along the way which is why the covers at 
Manning and Amazon are different at the moment. Same book though :-)


[1] http://manning.com/black2
[2] http://tinyurl.com/twgramz

-- 
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting  training: http://www.rubypal.com
Now available: The Well-Grounded Rubyist (http://manning.com/black2)
Ruby 1.9: What You Need To Know Envycasts with David A. Black
http://www.envycasts.com


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



[Rails] converting created_at to the number of days ago format

2009-05-12 Thread Charanya Nagarajan

Hi

I want to display the created_at field of my model in the format n days
ago n hours ago

Please help me in this
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] what to use for sanitize?

2009-05-12 Thread fausto

Hi, i'm allowing users to upload html stuff, what can i use to
sanitize it? h() it's not good as it escape everything, and i've found
that the rails sanitize() is too strict, it sanitize also css style
attributes, so users cannot personalize their html... i'd like
something which permit to include code like youtubbbe embedded, css
styles (only inline, not by external link), which strip stuff like
html, head and keep just the body, and all the script tags or btw
everything which could cause xss and other problems... what do you
suggest?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Upload file with url parameter

2009-05-12 Thread PyroHiroshi

This is exactly what I've been trying to do all day. Not as easy as
you'd think. There are absolutely no examples of this available
anywhere.

It's a wonder that people haven't been trying to do this for a while
'cause it has many different uses, like streaming data directly
through the 80 port when all other ports are blocked.

B

On May 11, 12:39 pm, Frederick Cheung frederick.che...@gmail.com
wrote:
 On May 11, 11:11 am, hongseok.com hongseok.y...@gmail.com wrote: I just 
 want the client(kind a application running automatically) to
 uploadfileto the web server as it wants.

  How do I do this?

 you'll need to construct an appropriate post request (read up on
 multipart post requests) containing thefile

 Fred

  On 5월11일, 오후5시53분, Frederick Cheung frederick.che...@gmail.com
  wrote:

   On May 11, 7:52 am, hongseok.com hongseok.y...@gmail.com wrote:

I want touploadfileusing get method.
for example, http://www.mydomain.com/upload?file=c:\test.exeupload
my localfileto the remote server.
I found one useful link aboutfileuploading 
here(http://www.tutorialspoint.com/ruby-on-rails/rails-file-uploading.htm).
Even I've changed some code in order to fit my rails version, it
worked well. But the problem is I have use form tag.

I don't know how [view] make UploadedFile and pass it to [controller]
and I tried to find how create UploadedFile. But failed :(

Anyway, how can Iuploadmy localfileusing above styleurl?

   If you want to just pass the path of thefilethat won't work - the
  fileneeds to be part of the request body. In theory get requests can
   have a request body, but certainly in browser land this isn't common.
   it might just work if you set the form's method to get (don't forget
   to make the form multipart).
   Why is this important ?

   Fred

help me plz, thx

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



[Rails] Unused local variable load_error in boot.rb

2009-05-12 Thread wayne.sima...@gmail.com

I'm getting an 'Unused local variable load_error' in my .config/
boot.rb

This seems to be the problem code:

rescue Gem::LoadError = load_error
  $stderr.puts %(Missing the Rails #{version} gem. Please `gem
install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in
config/environment.rb for the Rails version you do have installed, or
comment out RAILS_GEM_VERSION to use the latest version installed.)
  exit 1
end

Should I put in my current Rails version?
What is this looking for?
Will this freeze my system?
Do I have to change this when I update gems or rails?

My .config/environment.rb file reads as follows [comments removed]

   RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
   require File.join(File.dirname(__FILE__), 'boot')
   Rails::Initializer.run do |config|
   config.time_zone = 'UTC'
end

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



[Rails] Re: Yet another cucumber/webrat/selenium problem

2009-05-12 Thread WJSimacek



On May 12, 7:09 am, John Small rails-mailing-l...@andreas-s.net
wrote:
 I do wish Cucumber has its own Google group, but no such luck (or at
 least it's not linked to from GitHub), so I'll post here.

John,
 Cucumber gets a lot of posts on the rspec group. You can link to
it here:
http://groups.google.com/group/rspec?hl=en

  It's a pretty active group with some smart people. Good luck on
your BDD.

Wayne


 I've followed the instructions for setting up 
 onhttp://wiki.github.com/aslakhellesoy/cucumber/setting-up-selenium.

 I get responses that look like it's about to work, Firefox starts,
 Selenium takes controls and then it all falls apart. Like this;-

 == Waiting for Selenium RC server on port ... Ready!
 == Waiting for rails application server on port 3001... Ready!
 12:55:48.301 WARN - you appear to be changing domains 
 fromhttp://localhost:3001tohttp://www.example.com/customer_login
 this may lead to a 'Permission denied' from the browser (unless it is
 running as *iehta or *chrome,
 or alternatively the selenium server is running in proxy injection mode)

 Where is the hidden configuration setting that allows me to issue
 requests to localhost:3001 when I'm using Cucumber with Webrat with
 Selenium?

 Thanks

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



[Rails] Re: converting created_at to the number of days ago format

2009-05-12 Thread Vladimir Rybas

Sorry, that should be
(Time.now.to_i - Time.at(@model.created_at.to_i).to_i)

and there are questions about timezones and stuff. You need to watch
it carefully.

On May 12, 7:38 pm, Vladimir Rybas vladimirry...@gmail.com wrote:
 @seconds_from_model_creation = (Time.now.to_i - Time.at
 (@model.created_at).to_i)
 @days_from_creation = @seconds_from_model_creation / (60*60*24)
 ...

 On May 12, 6:48 pm, Charanya Nagarajan rails-mailing-l...@andreas-

 s.net wrote:
  Hi

  I want to display the created_at field of my model in the format n days
  ago n hours ago

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



[Rails] Implementing ruby-openid 2.1.6 using TDD

2009-05-12 Thread wayne.sima...@gmail.com

I'm trying to implement ruby-openid 2.1.6 using TDD. Many of the
resources I've been using to research the plugin
open_id_authentication and RESTful-authentication were written back in
2007 and don't work, and also don't have a test-driven approach.

Does anyone know where I can find some good resources that would
explain and maybe have some examples with some tests and also how they
are getting them to pass, that is also fairly current?

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



[Rails] SocketError (getaddrinfo: Name or service not known)

2009-05-12 Thread daociyiyou

I want write image(thumbnail is binary data) to
ftp://showreelfinder.com/www.showreelfinder.com/web/site/temp/uploads/heywatch
directory. But i got error like following:

SocketError (getaddrinfo: Name or service not known)

My writing codes like this:
 
  ftp_host=ftp://showreelfinder.com;
  ftp=Net::FTP.new(ftp_host,heywatch,JRnu4bNtXl)
  ftp.login
  ftp.putbinaryfile(thumbnail,www.showreelfinder.com/web/site/temp/
uploads
  /heywatch+encoded_video.title)#thumbnail is binary data
  ftp.close
###
  puttextfile(localfile, remotefile = File.basename(localfile)) {|
line| ...},the localfile params can not be  binary data? or
remotefile must exist on ftp server?


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



[Rails] Re: SocketError (getaddrinfo: Name or service not known)

2009-05-12 Thread Tom Z Meinlschmidt

remove ftp:// from you ftp_host variable

daociyiyou wrote:
 I want write image(thumbnail is binary data) to
 ftp://showreelfinder.com/www.showreelfinder.com/web/site/temp/uploads/heywatch
 directory. But i got error like following:
 
 SocketError (getaddrinfo: Name or service not known)
 
 My writing codes like this:
  
   ftp_host=ftp://showreelfinder.com;
   ftp=Net::FTP.new(ftp_host,heywatch,JRnu4bNtXl)
   ftp.login
   ftp.putbinaryfile(thumbnail,www.showreelfinder.com/web/site/temp/
 uploads
   /heywatch+encoded_video.title)#thumbnail is binary data
   ftp.close
 ###
   puttextfile(localfile, remotefile = File.basename(localfile)) {|
 line| ...},the localfile params can not be  binary data? or
 remotefile must exist on ftp server?
 
 
 Thanks!
 

-- 
===
Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache

www.meinlschmidt.com  www.maxwellrender.cz  www.lightgems.cz
===

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



[Rails] Re: Where to put additional code for model.

2009-05-12 Thread Jim Burgess

Ok, cheers for that.
I guess I will have to rethink my approach.
In defense of my current method, to make sure the date field doesn't 
accept incorrect input I use ruby's 'Date.strptime' to parse the string 
as a date. If it works then everything is ok, if it throws an error then 
I catch this and output the error message that the date is invalid.

 that make no difference?
 You can, of course, do your own sanitizing of input data. But in this
 particular case I don't see the point. You still need to avoid anomalies
 like February, 31st. I don't see any advantage in doing this stuff
 yourself instead of giving ActiveRecord a chance and mop up in case it
 indicates a problem. Don't get to enamored with your current approach.

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

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



[Rails] Re: Help with MySQL COALESCE

2009-05-12 Thread tni

I am not specifically setting that field in the view as you suggested,
which was a good idea.
I am using the collection returned by running the find to feed a
filter function which is defining the filter fields being used
to build queries.  I really needed to have the collection contain the
appropriate data before being passed into the
filter code

On May 11, 10:52 pm, Andrew Timberlake and...@andrewtimberlake.com
wrote:
 On Mon, May 11, 2009 at 7:02 PM, tni tere...@ucia.gov wrote:

  In my Ruby on Rails app, I am trying to run a query to populate a drop-
  down select box.  The query may return NULL values, in which case I
  want to display a value like 'N/A'.
  My query works directly in MySql:
  select distinct(coalesce(time, N/A)) from mytable;

  But when I run this in the app using mytable.find(),
  the null value is returned as a 0.  The database column is an integer.
  Is Ruby somehow changing my desired value to 0 because it's an
  integer??
  Again, I get the desired results in MySql.

  In Ruby on Rails, how can I replace the NULL value with some text
  value that will make more sense to
  the user?

 Yes, Rails is changing the value to an int because of the db schema.
 Rails will return nil if the field is null so why don't you just do
 the 'COALESCE' in rails

 %= my_table.time || 'N/A' %

 Andrew 
 Timberlakehttp://ramblingsonrails.comhttp://www.linkedin.com/in/andrewtimberlake

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



[Rails] Re: Where to put additional code for model.

2009-05-12 Thread Ar Chron

Jim Burgess wrote:
 
 At the moment it is sitting at the top of my model, but the method is
 quite long and this looks a bit ugly / cluttered.
 

Sometimes code is ugly no matter what... ;)

I remember having to account for the difference between little-endian 
veruss big-endian architectures on a project, and writing a whole 
comment paragraph about just why I was twiddling two bytes of data in 
the buffer stream before extracting it into the long int I wanted...

 Is there anywhere else I can put this code?

If it belongs to the model, it should be in the model, unless it really 
is a larger 'sub-system' that merits its own module.

Of course, it *could* always be just the first entry into your 
'application_extensions' module as well, but when I find modules with 
just one or two methods that are only used by one class, there's a 'Why 
oh why?' moment.

Just my $0.02.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: nested hash and nil question

2009-05-12 Thread scott

that will work perfect, thanks

On May 12, 3:01 am, Ryan Waldron r...@erebor.com wrote:
 What value should 'zip' contain if postal_code_number doesn't exist (or any
 of the keys above it)?

 If one of the keys in that long nasty chain are nil, you're going to get an
 exception, but if you know an acceptable default value in case you can't
 eval the whole expression, rescue the exception and return what you want.

 If you want it to be an empty string, for instance, you could do:

 zip =
 placemark['address_details']['country']['administrative_area']['locality'][ 
 'postal_code']['postal_code_number']
 rescue ''



 On Tue, May 12, 2009 at 12:53 AM, scott scot...@gmail.com wrote:

  i need to pull out some specific values from a nested hash, but nils
  are driving me crazy. in the following example, if address_details,
  country, administrative_area, locality OR postal_code are nil i get
  The error occurred while evaluating nil.[]

  zip = placemark['address_details']['country']['administrative_area']
  ['locality']['postal_code']['postal_code_number']

  i tried

  unless placemark['address_details']['country']['administrative_area']
  ['locality']['postal_code']['postal_code_number'].nil?

  but if anything above postal_code_number is nil i still get the error.
  i could check each level but that is really ugly.

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



[Rails] Re: Two level Navigational menus

2009-05-12 Thread Bharat

I am using jQuery now and am interested in using Superfish.  Can you
point me to a working example of Superfish and RoR integration?
Thanks.
Bharat

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



[Rails] Re: trouble linking models

2009-05-12 Thread p_W

I know this doesn't help the core problem, but it might help in
debugging to set that column to 'NOT NULL' in your database, and set a
default value.

On May 11, 8:26 am, Tom Z Meinlschmidt to...@meinlschmidt.org wrote:
 Sean,
 did you check your database? Is user_id filled up correctly?

 tom

 Sean Six wrote:
  Class User  ActiveRecord::Base
   has_many :articles

  class Article  ActiveRecord::Base
   belongs_to :user

  After a user posts an article, I want to include their username.  I
  presume I should just be able to use %= article.user.screen_name  % in
  the articles/index.
  This give me:

  You have a nil object when you didn't expect it!
  The error occurred while evaluating nil.screen_name

 --
 ===
 Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache

 www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz
 ===

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



[Rails] a problem http POST params

2009-05-12 Thread Learning

this is my HTML:
form method = post action = form/index
input type = text name = username /
/form

and the form_controller:
class FormController  ApplicationController
  def index
  @username=params[:username]
  end
end

what's wrong about this? it works with GET method.
but the API shows that params() Returns both GET and POST \parameters
in a single hash.
there's the error message below

 ActionController::InvalidAuthenticityToken in FormController#index

ActionController::InvalidAuthenticityToken

RAILS_ROOT: /home/Learning/workspace/myapp
Application Trace | Framework Trace | Full Trace

/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
request_forgery_protection.rb:79:in `verify_authenticity_token'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
callbacks.rb:178:in `send'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
callbacks.rb:178:in `evaluate_method'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
callbacks.rb:166:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
filters.rb:225:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
filters.rb:629:in `run_before_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
filters.rb:615:in `call_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
filters.rb:610:in `perform_action_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
rescue.rb:160:in `perform_action_without_flash'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
flash.rb:141:in `perform_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
base.rb:523:in `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
base.rb:523:in `process_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
filters.rb:606:in `process'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
base.rb:391:in `process'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
base.rb:386:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
routing/route_set.rb:433:in `call'

/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
request_forgery_protection.rb:79:in `verify_authenticity_token'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
callbacks.rb:178:in `send'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
callbacks.rb:178:in `evaluate_method'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
callbacks.rb:166:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
filters.rb:225:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
filters.rb:629:in `run_before_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
filters.rb:615:in `call_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
filters.rb:610:in `perform_action_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
core_ext/benchmark.rb:17:in `ms'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
rescue.rb:160:in `perform_action_without_flash'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
flash.rb:141:in `perform_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
base.rb:523:in `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
base.rb:523:in `process_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
filters.rb:606:in `process'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
base.rb:391:in `process'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
base.rb:386:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
routing/route_set.rb:433:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
dispatcher.rb:88:in `dispatch'

[Rails] Re: SocketError (getaddrinfo: Name or service not known)

2009-05-12 Thread Tom Z Meinlschmidt

ftp.putbinaryfile(thumbnail,ftp://showreelfinder.com/
www.showreelfinder.com/web/site/temp/uploads/heywatch/+encoded_video.title)

change to

ftp.putbinaryfile(thumbnail,/www.showreelfinder.com/web/site/temp/uploads/heywatch/+encoded_video.title)

tom

daociyiyou wrote:
 Thanks. But i got another error:
 
 
 Net::FTPPermError (500 Unknown command. ):
 
 
 So i changed the codes according to my guess:
 
 
   ftp_host=showreelfinder.com
   ftp=Net::FTP.new(ftp_host,heywatch,JRnu4bNtXl)
   ftp.login
   ftp.putbinaryfile(thumbnail,ftp://showreelfinder.com/
 www.showreelfinder.com/web/site/temp/uploads/heywatch/+encoded_video.title)
   ftp.close
 
 
 I still get the error:
 
 
 Net::FTPPermError (500 Unknown command. ):
 
 I want write the binary data(thumbnail) to the ftp address (ftp://
 showreelfinder.com/www.showreelfinder.com/web/site/temp/uploads/
 heywatch/+encoded_video.title),the encoded_video.title file does not
 exist on ftp server.
 so how do i manage?
 

-- 
===
Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache
  - experienced RoR/PHP freelancer, available for hire

   www.meinlschmidt.com  www.maxwellrender.cz  www.lightgems.cz
===

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



[Rails] Re: SocketError (getaddrinfo: Name or service not known)

2009-05-12 Thread Tom Z Meinlschmidt

back, your code is wrong

  ftp = Net::FTP.new(ftp_host)
  ftp.login('username','password')
  ftp.chdir('/www.showreelfinder.com/web/site/temp/uploads/heywatch/')
  ftp.putbinaryfile(thumbnail, encoded_video.title)
  ftp.close

tom

daociyiyou wrote:
 Thanks. But i got another error:
 
 
 Net::FTPPermError (500 Unknown command. ):
 
 
 So i changed the codes according to my guess:
 
 
   ftp_host=showreelfinder.com
   ftp=Net::FTP.new(ftp_host,heywatch,JRnu4bNtXl)
   ftp.login
   ftp.putbinaryfile(thumbnail,ftp://showreelfinder.com/
 www.showreelfinder.com/web/site/temp/uploads/heywatch/+encoded_video.title)
   ftp.close
 
 
 I still get the error:
 
 
 Net::FTPPermError (500 Unknown command. ):
 
 I want write the binary data(thumbnail) to the ftp address (ftp://
 showreelfinder.com/www.showreelfinder.com/web/site/temp/uploads/
 heywatch/+encoded_video.title),the encoded_video.title file does not
 exist on ftp server.
 so how do i manage?
 

-- 
===
Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache
  - experienced RoR/PHP freelancer, available for hire

   www.meinlschmidt.com  www.maxwellrender.cz  www.lightgems.cz
===

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



[Rails] Re: what to use for sanitize?

2009-05-12 Thread Matt Jones

Good luck with that - it's not (in general) possible to do this. Even
if you kill off all the scripting, with some CSS knowledge, a
malicious user could make a fake login page and phish people.

Little things like IE6 and 7's support of javascript in CSS attributes
could also cause trouble...

--Matt Jones

On May 12, 6:52 am, fausto fausto.ga...@email.it wrote:
 Hi, i'm allowing users to upload html stuff, what can i use to
 sanitize it? h() it's not good as it escape everything, and i've found
 that the rails sanitize() is too strict, it sanitize also css style
 attributes, so users cannot personalize their html... i'd like
 something which permit to include code like youtubbbe embedded, css
 styles (only inline, not by external link), which strip stuff like
 html, head and keep just the body, and all the script tags or btw
 everything which could cause xss and other problems... what do you
 suggest?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: SocketError (getaddrinfo: Name or service not known)

2009-05-12 Thread daociyiyou

I have changed to ftp.putbinaryfile(thumbnail,/www.showreelfinder.com/
web/site/temp/uploads/heywatch/+encoded_video.title) and still got
that error.  Then i changed  to

ftp.putbinaryfile(thumbnail,/www.showreelfinder.com/web/site/temp/
uploads/heywatch/+encoded_video.title+.jpg)

The same error happend.

On 5月13日, 上午12时25分, Tom Z Meinlschmidt to...@meinlschmidt.org wrote:
 ftp.putbinaryfile(thumbnail,ftp://showreelfinder.com/www.showreelfinder.com/web/site/temp/uploads/heywatch/+encoded_video.title)

 change to

 ftp.putbinaryfile(thumbnail,/www.showreelfinder.com/web/site/temp/uploads/heywatch/+encoded_video.title)

 tom



 daociyiyou wrote:
  Thanks. But i got another error:

  
  Net::FTPPermError (500 Unknown command. ):
  

  So i changed the codes according to my guess:

  
ftp_host=showreelfinder.com
ftp=Net::FTP.new(ftp_host,heywatch,JRnu4bNtXl)
ftp.login
ftp.putbinaryfile(thumbnail,ftp://showreelfinder.com/
 www.showreelfinder.com/web/site/temp/uploads/heywatch/+encoded_video.title)
ftp.close
  

  I still get the error:

  
  Net::FTPPermError (500 Unknown command. ):
  
  I want write the binary data(thumbnail) to the ftp address (ftp://
  showreelfinder.com/www.showreelfinder.com/web/site/temp/uploads/
  heywatch/+encoded_video.title),the encoded_video.title file does not
  exist on ftp server.
  so how do i manage?

 --
 ===
 Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache
   - experienced RoR/PHP freelancer, available for hire

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



[Rails] Re: has_many :through and scopes: how to mutate the set of associated objects?

2009-05-12 Thread Matt Jones

Haven't tried it, but have you considered switching the association
extension to a regular named_scope on Person? For simpler cases, I
know that the named_scope code is smart enough to use the scope
conditions to instantiate objects. Not sure if it will work here...

--Matt Jones

On May 11, 7:34 pm, Michael Schuerig mich...@schuerig.de wrote:
 I have a model layer containing Movie, Person, Role, and RoleType,
 making it possible to express facts such as Clint Easterbunny is
 director of the movie Gran Milano.

 The relevant model and associations look like this

 class Movie  ActiveRecord::Base
   has_many :roles, :include = :role_type, :dependent = :destroy

   has_many :participants, :through = :roles, :source = :person do
     def as(role_name)
       self.scoped(
         :joins = 'CROSS JOIN role_types',
         :conditions = [
           (roles.role_type_id = role_types.id) +
            AND role_types.name = ?,
           role_name
         ]
       )
     end
   end
   ...
 end

 Querying is easy:

 m = Movie.find_by_title('Gran Milano')
 m.participants.as('director')

 However, changing relations is painful. It's already bad with has_many
 :through associations when the intermediate model is not completely
 dumb, and my scope trickery doesn't make it any better.

 Now, let's assume for a moment that participants was a plain has_many
 association. Then it would be possible to write things like

 m.participants.clear
 m.participants  Person.find_by_name('Steve McKing')
 m.participant_ids = params[:movie][:participants]

 With the given has_many :through, none of these work, as Role object
 won't validate without a role type. Anyway, what I would like to write
 is

 m.participants.as('actor').clear
 m.participants.as('actor')  Person.find_by_name('Steve McKing')
 m.participants.as('actor') = Person.find(params[:movie][:participants])

 I'm not sure this is possible with ActiveRecord as it is, but I'm
 looking forward to suggestions.

 Michael

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



[Rails] Date/Time problems on Windows

2009-05-12 Thread Piers Denney

Hi All,

I have a system running on Win Server2003 and SqlServer 2008.

Machine is set to GMT-6 for its timezone i.e Central Time with
Daylight Savings enabled.

When I add records, the time shown in the fields is shown in UTC - as
its the current time +5 hours. The times stored in the DB are as
entered (I checked in SQL) in UTC. When the records are retrieved then
get another 5 hours added to them, as if they were stored in local
time.

The environment.rb file shows:

 config.time_zone = 'UTC'

I dont care if the records are stored in UTC or not, but this wacked
out date handling is killing the users as its so confusing. Any ideas/
solutions?

Many thanks in advance

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



[Rails] Re: what database field type should i use ??

2009-05-12 Thread lukasw

Though you might already have solved your issue at hand, I've recently
ran into a similar situation and written a small plugin for it,
columns are backed by integers, but in ruby you can treat them using
symbols or whatever:

class User  ActiveRecord::Base
  as_enum :status, { :single = 0, :married = 1, :divorced = 2 }
end

Then create an integer column:

add_column :users, :status_cd, :integer

It's then possible to easily access these values using @user.status:

@user = User.new
@user.status = :married # = implies @user.status_cd = 1

For my problem I also required some shorthands to check for values, so
I've added also symbol? methods:

@user.married? # = true
@user.single?  # = false

The code lives at github http://github.com/lwe/simple_enum/tree/master
any feedback is appreciated

cheers, lukas

On May 7, 10:43 am, Vipin sh.vi...@gmail.com wrote:
 in a database table if there is a field which has a certain set of
 fixed values. for example
 staus = {Single, Married, Divorced }
 OR
 state = {California, Albama, Olaska ...}

 so what should be preferred way out of the following for storing the
 values

 1. Keep the field as string(Rails)  VARCHAR(MySQL) itself and
 while showing the field just show the field value.

 2. Keep the field internally as a code like {:california =
 01, :albama = 02, washington = 03 } but while showing the state
 show only the corresponding state.

 By using option 2, a certain disadvantage is extra computation time
 required to find out corresponding state name based on code when
 showing the state field to user. But an advantage could be in terms of
 smaller database. In my opinion, saving 01 as an integer could save
 significant space than storing california  if number of records
 happen to be in tens of thousands .

 please suggest ??

 vipin

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



[Rails] Re: SocketError (getaddrinfo: Name or service not known)

2009-05-12 Thread daociyiyou

Thanks.
I have changed the wrong codes but got the third error:
##
Net::FTPPermError (550 Failed to change directory. )
#
My ftp complete directory is
ftp://showreelfinder.com/www.showreelfinder.com/web/site/temp/uploads/heywatch/

On 5月13日, 上午12时29分, Tom Z Meinlschmidt to...@meinlschmidt.org wrote:
 back, your code is wrong

   ftp = Net::FTP.new(ftp_host)
   ftp.login('username','password')
   ftp.chdir('/www.showreelfinder.com/web/site/temp/uploads/heywatch/')
   ftp.putbinaryfile(thumbnail, encoded_video.title)
   ftp.close

 tom



 daociyiyou wrote:
  Thanks. But i got another error:

  
  Net::FTPPermError (500 Unknown command. ):
  

  So i changed the codes according to my guess:

  
ftp_host=showreelfinder.com
ftp=Net::FTP.new(ftp_host,heywatch,JRnu4bNtXl)
ftp.login
ftp.putbinaryfile(thumbnail,ftp://showreelfinder.com/
 www.showreelfinder.com/web/site/temp/uploads/heywatch/+encoded_video.title)
ftp.close
  

  I still get the error:

  
  Net::FTPPermError (500 Unknown command. ):
  
  I want write the binary data(thumbnail) to the ftp address (ftp://
  showreelfinder.com/www.showreelfinder.com/web/site/temp/uploads/
  heywatch/+encoded_video.title),the encoded_video.title file does not
  exist on ftp server.
  so how do i manage?

 --
 ===
 Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache
   - experienced RoR/PHP freelancer, available for hire

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



[Rails] Re: has_many :through and scopes: how to mutate the set of associated objects?

2009-05-12 Thread Michael Schuerig

On Tuesday 12 May 2009, Matt Jones wrote:
 Haven't tried it, but have you considered switching the association
 extension to a regular named_scope on Person? For simpler cases, I
 know that the named_scope code is smart enough to use the scope
 conditions to instantiate objects. Not sure if it will work here...

If I understand you correctly, I've already considered that case.

class Person  ActiveRecord::Base
  named_scope :actors, ... # add a condition picking out the actors
end

Then, with 

movie.participants.actors

I'd get the people who are participating in movie and who are actors. 
However, what I want are the people participating in movie *as* actors.

It might be possible to get this to work as intended, but I tend to 
think it's not. Dealing with the joins involved is already tricky. 
ActiveRecord (almost) doesn't have an abstract model of queries, it more 
or less concatenates strings. There's no support for expressing, on the 
one hand, that a specific join is needed (without duplicating it), and 
on the other, that you want another, independent join.

Michael

 On May 11, 7:34 pm, Michael Schuerig mich...@schuerig.de wrote:
  I have a model layer containing Movie, Person, Role, and RoleType,
  making it possible to express facts such as Clint Easterbunny is
  director of the movie Gran Milano.
 
  The relevant model and associations look like this
 
  class Movie  ActiveRecord::Base
has_many :roles, :include = :role_type, :dependent = :destroy
 
has_many :participants, :through = :roles, :source = :person do
  def as(role_name)
self.scoped(
  :joins = 'CROSS JOIN role_types',
  :conditions = [
(roles.role_type_id = role_types.id) +
 AND role_types.name = ?,
role_name
  ]
)
  end
end
...
  end
 
  Querying is easy:
 
  m = Movie.find_by_title('Gran Milano')
  m.participants.as('director')
 
  However, changing relations is painful. It's already bad with
  has_many
 
  :through associations when the intermediate model is not completely
 
  dumb, and my scope trickery doesn't make it any better.
 
  Now, let's assume for a moment that participants was a plain
  has_many association. Then it would be possible to write things
  like
 
  m.participants.clear
  m.participants  Person.find_by_name('Steve McKing')
  m.participant_ids = params[:movie][:participants]
 
  With the given has_many :through, none of these work, as Role
  object won't validate without a role type. Anyway, what I would
  like to write is
 
  m.participants.as('actor').clear
  m.participants.as('actor')  Person.find_by_name('Steve McKing')
  m.participants.as('actor') =
  Person.find(params[:movie][:participants])
 
  I'm not sure this is possible with ActiveRecord as it is, but I'm
  looking forward to suggestions.
 
  Michael



-- 
Michael Schuerig
mailto:mich...@schuerig.de
http://www.schuerig.de/michael/


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



[Rails] Re: SocketError (getaddrinfo: Name or service not known)

2009-05-12 Thread Tom Z Meinlschmidt

so you have to check the directory manually

I suppose change chdir to web/site/temp/uploads/heywatch ...

tom

daociyiyou wrote:
 Thanks.
 I have changed the wrong codes but got the third error:
 ##
 Net::FTPPermError (550 Failed to change directory. )
 #
 My ftp complete directory is
 ftp://showreelfinder.com/www.showreelfinder.com/web/site/temp/uploads/heywatch/
 
 On 5月13日, 上午12时29分, Tom Z Meinlschmidt to...@meinlschmidt.org wrote:
 back, your code is wrong

   ftp = Net::FTP.new(ftp_host)
   ftp.login('username','password')
   ftp.chdir('/www.showreelfinder.com/web/site/temp/uploads/heywatch/')
   ftp.putbinaryfile(thumbnail, encoded_video.title)
   ftp.close

 tom



 daociyiyou wrote:
 Thanks. But i got another error:
 
 Net::FTPPermError (500 Unknown command. ):
 
 So i changed the codes according to my guess:
 
   ftp_host=showreelfinder.com
   ftp=Net::FTP.new(ftp_host,heywatch,JRnu4bNtXl)
   ftp.login
   ftp.putbinaryfile(thumbnail,ftp://showreelfinder.com/
 www.showreelfinder.com/web/site/temp/uploads/heywatch/+encoded_video.title)
   ftp.close
 
 I still get the error:
 
 Net::FTPPermError (500 Unknown command. ):
 
 I want write the binary data(thumbnail) to the ftp address (ftp://
 showreelfinder.com/www.showreelfinder.com/web/site/temp/uploads/
 heywatch/+encoded_video.title),the encoded_video.title file does not
 exist on ftp server.
 so how do i manage?
 --
 ===
 Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache
   - experienced RoR/PHP freelancer, available for hire

www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz
 ===
 

-- 
===
Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache
 - experienced RoR/PHP freelancer, available for hire

  www.meinlschmidt.com  www.maxwellrender.cz  www.lightgems.cz
===

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



[Rails] Re: Running rake test:units yields DEPRECIATION WARNING: Disabling sessions for a single controller...

2009-05-12 Thread WJSimacek



On May 12, 7:43 am, wayne.sima...@gmail.com
wayne.sima...@gmail.com wrote:
 When I run my rake test:units I get the following:

 DEPRECATION WARNING: Disabling sessions for a single controller has
 been deprecated. Sessions are now lazy loaded. So if you don't access
 them, consider them off. You can still modify the session cookie
 options with request.session_options.. (called from C:/Users/Wayne/
 Documents/Aptana Studio/chores/app/controllers/
 application_controller.rb:10)
 Loaded suite C:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake/
 rake_test_loader
 Started
 ..EEE
 Finished in 2.086 seconds.

 What am I doing that has been deprecated?

I commented out the following line in my .app/controllers/
application_controller.rb which removed this warning.

 session :session_key = '_openidauth_session_id'


 How do I fix?

It looks like you no longer put session information in your
controllers.


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



[Rails] @new_record_before_save

2009-05-12 Thread TomRossi7

Is there an easy way to access the ActiveRecord
@new_record_before_save attribute?

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



[Rails] Re: @new_record_before_save

2009-05-12 Thread Philip Hallstrom

 Is there an easy way to access the ActiveRecord
 @new_record_before_save attribute?

Maybe...

  u = User.new
  u.new_record?
= 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 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Where to put additional code for model.

2009-05-12 Thread p_W

So this won't fix the problem of user input outside the browser, but
what about implementing the date fields as select's instead of text
fields?  You will still have to sanitize the data but at least you
have defined the format in which the user inputs it through the
browser.

On May 12, 10:09 am, Ar Chron rails-mailing-l...@andreas-s.net
wrote:
 Jim Burgess wrote:

  At the moment it is sitting at the top of my model, but the method is
  quite long and this looks a bit ugly / cluttered.

 Sometimes code is ugly no matter what... ;)

 I remember having to account for the difference between little-endian
 veruss big-endian architectures on a project, and writing a whole
 comment paragraph about just why I was twiddling two bytes of data in
 the buffer stream before extracting it into the long int I wanted...

  Is there anywhere else I can put this code?

 If it belongs to the model, it should be in the model, unless it really
 is a larger 'sub-system' that merits its own module.

 Of course, it *could* always be just the first entry into your
 'application_extensions' module as well, but when I find modules with
 just one or two methods that are only used by one class, there's a 'Why
 oh why?' moment.

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



[Rails] MySQL Text type failure

2009-05-12 Thread JannaB

This is very peculiar --  I am using (I am using MySQL 5.0.27-
community) If I create a table with the following schema.

CREATE TABLE `associates` (
  `id` int(11) NOT NULL auto_increment,
  `username` varchar(16) NOT NULL default '',
 ...
 ...
  `tstamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update
CURRENT_TIMESTAMP,
  PRIMARY KEY  (`id`),
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=27 ;

things in AS work swimmingly. However, if I add a column (anywhere in
the table, here I am just putting at the end) that is a text type,
call it   `notes` (or even make, say varchar(500) ) as follows:

CREATE TABLE `associates` (
  `id` int(11) NOT NULL auto_increment,
  `username` varchar(16) NOT NULL default '',
 ...
 ...
  `tstamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update
CURRENT_TIMESTAMP,
  `notes` text NOT NULL,
  PRIMARY KEY  (`id`),
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=27 ;

When I go to do an edit on the table, regardless of whether I add any
data to the notes field or not, and I save it, It won't come back up
when I go to edit it again (I get a 500 error). It saves the values
into the db correctly when I go directly into the db and look at the
changes -- but it wont come back up when I go to edit it without
generating
a 500 error.

I am using the latest version of Rails (2.3) , Ruby and
ActiveScaffold. Has anyone
experienced anything like this trying to use a large text field with
MySQL ?
thank you, Janna B
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] has_many :through , extra data retrieval.

2009-05-12 Thread Me

I have a has_many :through  companies - markets with emails as the
join table.

The view is relatively easy:

% form_for :market, :html = { :id = 'marketform' } do |f|%
%= hidden_field_tag company[companyid], @company.id, :index =
@company.id %
% for market in @markets %
div
%= check_box_tag company[market_attributes][], 
market.id,
@company.markets.include?(market) %
%= label_tag :market_ids, market.name.upcase -%
span style=align: right;%= text_field_tag 
emaildistro[#
{market.id}] %/span
/div
% end %
input type=submit value=Update Markets onclick=Modalbox.show('/
markets/create', {method: 'post' ,title: 'Sending status', params:
Form.serialize('marketform') }); return false; /
% end %

controller:

company = Contactcompany.find(params[:company][:companyid])
  markets = params[:company][:market_attributes] ||= []
  company.market_ids = markets
  company.emails.each{|mail|
distro = params[:emaildistro][#{mail.market.id}]
mail.update_attributes(:emaildistro = distro)
  }


Is there a way to retrieve the emails just like the checkboxes do when
you pull up the view?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: belong to and search

2009-05-12 Thread pharrington

If you want to retrieve just the name, than use the :select option
with your find:

@children = Child.find(:all, :include = :mother, :select = 'name')

On May 12, 11:04 am, Colin Law clan...@googlemail.com wrote:
 2009/5/12 Anthony Ward rails-mailing-l...@andreas-s.net



  Hi thank you

  so if I use the include
  how do i just retrieve the name then

 Do you mean you want a query finding the child, including the
 mother.namebut not the other mother fields?  I do not know whether you
 can do that.  I
 think the overhead of fetching all columns is going to be rather small.
 Colin



  example this is using the magic way

  @children do |child|

   ... print child.mother.name

  end

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



[Rails] Re: belong to and search

2009-05-12 Thread Colin Law
2009/5/12 pharrington xenogene...@gmail.com


 If you want to retrieve just the name, than use the :select option
 with your find:

 @children = Child.find(:all, :include = :mother, :select = 'name')


Does that select child.name or mother.name?
Colin



 On May 12, 11:04 am, Colin Law clan...@googlemail.com wrote:
  2009/5/12 Anthony Ward rails-mailing-l...@andreas-s.net
 
 
 
   Hi thank you
 
   so if I use the include
   how do i just retrieve the name then
 
  Do you mean you want a query finding the child, including the
  mother.namebut not the other mother fields?  I do not know whether you
  can do that.  I
  think the overhead of fetching all columns is going to be rather small.
  Colin
 
 
 
   example this is using the magic way
 
   @children do |child|
 
... print child.mother.name
 
   end
 
   --
   Posted viahttp://www.ruby-forum.com/.
 


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



[Rails] Re: Where to put additional code for model.

2009-05-12 Thread Aaron Brown

p_W wrote:
 So this won't fix the problem of user input outside the browser, but
 what about implementing the date fields as select's instead of text
 fields?  You will still have to sanitize the data but at least you
 have defined the format in which the user inputs it through the
 browser.

I recommend this setup for date entry since it does help a little with
the input sanitizing:  When you use a Select tag, the user input options
are known values and it allows you to be much more aggressive and
unforgiving with your input validation.  Text box input requires some
fuzzy acceptance of values, but a Select/Options list does not - you can
validate against a fixed set of values and anything else must have come
from a Bad Guy.

 - Aaron


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



[Rails] Re: what to use for sanitize?

2009-05-12 Thread pharrington

You can customize Rail's builtin sanitation by setting
config.action_view.sanitized_allowed_tags and such in your
environment.rb:

config.action_view.sanitized_allowed_tags %w[ list of additional html
tags to allow ]

You can do the similar with
config.action_view.sanitized_allowed_attributes,
sanitized_allowed_css_properties, and sanitized_allowed_css_keywords.
However, this is 1) fairly inflexible, as it affects the operation of
all sanitize() calls, and 2) sanitize uses Ruby Tokenizer, which is
slow. You might be better off looking into the Hpricot based Sanitize
gem (http://wonko.com/post/sanitize); however I myself haven't yet
used it, and it looks like its only geared toward HTML so I don't know
if it's able to sanitize css attributes.

On May 12, 12:37 pm, Matt Jones al2o...@gmail.com wrote:
 Good luck with that - it's not (in general) possible to do this. Even
 if you kill off all the scripting, with some CSS knowledge, a
 malicious user could make a fake login page and phish people.

 Little things like IE6 and 7's support of javascript in CSS attributes
 could also cause trouble...

 --Matt Jones

 On May 12, 6:52 am, fausto fausto.ga...@email.it wrote:

  Hi, i'm allowing users to upload html stuff, what can i use to
  sanitize it? h() it's not good as it escape everything, and i've found
  that the rails sanitize() is too strict, it sanitize also css style
  attributes, so users cannot personalize their html... i'd like
  something which permit to include code like youtubbbe embedded, css
  styles (only inline, not by external link), which strip stuff like
  html, head and keep just the body, and all the script tags or btw
  everything which could cause xss and other problems... what do you
  suggest?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: @new_record_before_save

2009-05-12 Thread Rob Biedenharn

On May 12, 2009, at 2:26 PM, TomRossi7 wrote:


 Is there an easy way to access the ActiveRecord
 @new_record_before_save attribute?

 Thanks,
 Tom


Well, it depends on what you mean by easy.

model.instance_variable_get('@new_record_before_save') will work

If you're using an older ActiveRecord and you are trying to tell the  
difference between a find_or_create_by_..., You can rely on the  
deprecated model.new_record?.nil? to know that it was a find  
(model.new_record? == false means it was actually a create)

-Rob

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



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



[Rails] Re: Where to put additional code for model.

2009-05-12 Thread Jim Burgess

 I recommend this setup for date entry since it does help a little with
 the input sanitizing:  When you use a Select tag, the user input options
 are known values and it allows you to be much more aggressive and
 unforgiving with your input validation.  Text box input requires some
 fuzzy acceptance of values, but a Select/Options list does not - you can
 validate against a fixed set of values and anything else must have come
 from a Bad Guy.

Hi,
Thanksfor the replies.
I've just been chatting with my brother-in-law who is a ruby programmer 
(considerably better than am I) and he pointed out that as I am calling 
the method which uses eval thus:
map_three_fields :dob_day, :dob_month, :dob_year, make_date, dob
the method doesn't accept any user input as arguments (only three 
symbols and two strings) and is therefore harmless.

So I guess I can stick with my original method after all.

Cheers
Jim


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

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



[Rails] Re: Upload file with url parameter

2009-05-12 Thread pharrington

Unless either someone develops a wonderful (i use the term *very*
loosely) exploit or I misunderstand what you're trying to do here,
there is no way to do what you're trying to do. Neither Javascript,
Flash, nor Java (unless the user's insane and sets up their JVM to do
this) can automatically read/serialize/change the value of a field  to
a local file. For very obvious security reasons, the only way to
upload a file with a web browser is for the user to actively select
the file they want, and then to send that in a POST request (GETs will
not work as you cannot serialize the file data).

On May 12, 8:07 am, PyroHiroshi bennet...@gmail.com wrote:
 This is exactly what I've been trying to do all day. Not as easy as
 you'd think. There are absolutely no examples of this available
 anywhere.

 It's a wonder that people haven't been trying to do this for a while
 'cause it has many different uses, like streaming data directly
 through the 80 port when all other ports are blocked.

 B

 On May 11, 12:39 pm, Frederick Cheung frederick.che...@gmail.com
 wrote:

  On May 11, 11:11 am, hongseok.com hongseok.y...@gmail.com wrote: I 
  just want the client(kind a application running automatically) to
  uploadfileto the web server as it wants.

   How do I do this?

  you'll need to construct an appropriate post request (read up on
  multipart post requests) containing thefile

  Fred

   On 5월11일, 오후5시53분, Frederick Cheung frederick.che...@gmail.com
   wrote:

On May 11, 7:52 am, hongseok.com hongseok.y...@gmail.com wrote:

 I want touploadfileusing get method.
 for example, http://www.mydomain.com/upload?file=c:\test.exeupload
 my localfileto the remote server.
 I found one useful link aboutfileuploading 
 here(http://www.tutorialspoint.com/ruby-on-rails/rails-file-uploading.htm).
 Even I've changed some code in order to fit my rails version, it
 worked well. But the problem is I have use form tag.

 I don't know how [view] make UploadedFile and pass it to [controller]
 and I tried to find how create UploadedFile. But failed :(

 Anyway, how can Iuploadmy localfileusing above styleurl?

If you want to just pass the path of thefilethat won't work - the
   fileneeds to be part of the request body. In theory get requests can
have a request body, but certainly in browser land this isn't common.
it might just work if you set the form's method to get (don't forget
to make the form multipart).
Why is this important ?

Fred

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



[Rails] Re: Upload file with url parameter

2009-05-12 Thread Starr Horne

The only way to do anything like that would be to have the user install a 
client on their computer. For example, you can upload arbitrary files using 
adobe air. But otherwise, is verboten.

SH
-- 
Starr Horne
Check out my Helpdesk RailsKit: http://railskits.com/helpdesk/


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



[Rails] Re: Date/Time problems on Windows

2009-05-12 Thread SIN-YOUNG DIVINESPEAR KANG

may the 'rake time:zones:local' will help you.
replace to one of that result.

Piers Denney wrote:
 Hi All,

 I have a system running on Win Server2003 and SqlServer 2008.

 Machine is set to GMT-6 for its timezone i.e Central Time with
 Daylight Savings enabled.

 When I add records, the time shown in the fields is shown in UTC - as
 its the current time +5 hours. The times stored in the DB are as
 entered (I checked in SQL) in UTC. When the records are retrieved then
 get another 5 hours added to them, as if they were stored in local
 time.

 The environment.rb file shows:

  config.time_zone = 'UTC'

 I dont care if the records are stored in UTC or not, but this wacked
 out date handling is killing the users as its so confusing. Any ideas/
 solutions?

 Many thanks in advance

 
   


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



[Rails] html sitemap

2009-05-12 Thread mumf83

Hi,

I'm trying to create a hierarchy html page of a sitemap from my
routes.rb file. Each entry needs to use its name and link to its page.
I keep finding stuff about using an XML sitmap but I don't want this
as I want it to be human readable. Can anyone help me with this? This
is my first project using Ruby on Rails so I might be missing
something really easy but havn't seen it yet.

Thanks.

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



[Rails] Re: Migrate VB.NET to ROR

2009-05-12 Thread s.ross

Hello--

On May 11, 2009, at 10:17 PM, GeoKid wrote:

 Hi,
 We are currently hitting among ourselves to see if there is migration
 tool/process in place to convert a VB.NET code base into ROR.
 Essentially, our product is currently a desktop version and one of the
 options for us is to adapt ASP.NET.  However, we wanted something more
 elegant - ROR.  Any thoughts,  rants, suggestions would be GREATLY
 appreciated. Thanks in advance.

I don't know how this will work for you, but if I were doing this, I  
would sit down with the existing app and write cucumber stories 
(http://cukes.info/ 
) that describe it and implement to make the scenarios pass. What that  
implies is that you will:

1. Install rails
2. Create a rails project
3. Install rspec and cucumber gems
4. Learn as you go how to use them

As far as I know there is no VB2Rails tool. But the benefit of  
creating the acceptance scenarios in cucumber and implementing to make  
them work is you wind up with a really good set of tests that will  
help keep your app stable. I'd also recommend reading the rSpec Book 
(http://www.pragprog.com/titles/achbd/the-rspec-book 
), currently in beta.

The test-first religion is an opinion shared by many in the Ruby  
community. Your mileage may vary.

Hope this is useful info.

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



[Rails] Re: Integration testing edit actions (PUT method)

2009-05-12 Thread Starr Horne

 What does people do here? ignore the fact that the integration test
 generate HTTP request which differs from what a broswer will do, or do
 you use post (or post_via_redirect) and adding the _method parameter
 manually.

I think you're just splitting hairs at that point. If the put request in your 
integration test doesn't get routed to the correct action, the test will fail 
anyway. 

SH

-- 
Starr Horne
Check out my Helpdesk RailsKit: http://railskits.com/helpdesk/


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



[Rails] Re: belong to and search

2009-05-12 Thread pharrington

Yeah I deleted that post immediately after because that selects
child.name. Something like :select = mothers.name AS mother_name
would probably work, but just ugly AND then you'd need a mother_name
virtual attribute in the Child model, making things rather needlessly
horrific. I really can't think of a good way (without raw SQL) to do
this in one query either.

On May 12, 3:33 pm, Colin Law clan...@googlemail.com wrote:
 2009/5/12 pharrington xenogene...@gmail.com



  If you want to retrieve just the name, than use the :select option
  with your find:

  @children = Child.find(:all, :include = :mother, :select = 'name')

 Does that select child.name or mother.name?
 Colin



  On May 12, 11:04 am, Colin Law clan...@googlemail.com wrote:
   2009/5/12 Anthony Ward rails-mailing-l...@andreas-s.net

Hi thank you

so if I use the include
how do i just retrieve the name then

   Do you mean you want a query finding the child, including the
   mother.namebut not the other mother fields?  I do not know whether you
   can do that.  I
   think the overhead of fetching all columns is going to be rather small.
   Colin

example this is using the magic way

@children do |child|

 ... print child.mother.name

end

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



[Rails] Re: Encrypt passwords in the database

2009-05-12 Thread Lakridserne

Thanks. I looked at it, but could not understand it. I will use md5
because I also use it in my PHP-applications, and I can therefore use
the same data without reset users passwords and so on. Can I do that
and how?

On 9 Maj, 17:38, Franco Catena francocat...@gmail.com wrote:
 You can use one of the Ruby digest 
 package:http://www.ruby-doc.org/stdlib/libdoc/digest/rdoc/index.html

 For example, if you want to digest a password with SHA 512:

 require 'digest/sha2'

 Digest::SHA2.hexdigest('password', 512)

 Regards.

 Franco Catena.

 On May 8, 6:18 pm, Lakridserne kristoffer.han...@stofanet.dk wrote:

  Hi,

  I know that there is a way to encrypt passwords, but what would be the
  easiest?
  For example you have 2 functions in php. You use them by calling:

  fuction(data-to-be-encrypted-here);

  But is there a similar way in ruby on 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 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Migrate VB.NET to ROR

2009-05-12 Thread E. Litwin

If the application was already an ASP.Net MVC app, then somebody could
develop an MVC-RoR tool a bit more easily.
However, you have a VB.Net desktop application. I don't believe there
is a tool that will convert it to an ASP.Net application either.

The best bet is to follow a BDD/TDD process (as a previous poster
recommended), regardless of whether you choose ASP.Net or RoR.

On May 11, 10:17 pm, GeoKid srikanth.pa...@gmail.com wrote:
 Hi,
 We are currently hitting among ourselves to see if there is migration
 tool/process in place to convert a VB.NET code base into ROR.
 Essentially, our product is currently a desktop version and one of the
 options for us is to adapt ASP.NET.  However, we wanted something more
 elegant - ROR.  Any thoughts,  rants, suggestions would be GREATLY
 appreciated. Thanks in advance.

 Peace,

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



[Rails] How much data can be stored in the cookie?

2009-05-12 Thread Chris Hanks

I've looked online, but I can't find a concrete answer to this. I'm
considering storing some data in the user's cookie, to be accessed by
javascript. It's not sensitive information, so security isn't a problem.

Altogether, I'm looking at two strings, one of which would be about 100
characters long, and the other closer to 1000 or 1500. Is that too much?

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

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



[Rails] Re: Deleting Sessions with no logout

2009-05-12 Thread Shandy Nantz

Colin Law wrote:
 I think you may find there is no reliable way of achieving this, there 
 was a
 significant thread on this issue a little while ago.
 What is the unwanted behaviour that you are seeing? Perhaps there is a
 better solution.
 Colin
 
 2009/5/11 Shandy Nantz rails-mailing-l...@andreas-s.net

It has to do with the sessions which are holding id for the current 
users logged in. At most, there may be three session variables set - the 
two above and another called session[:admin]. An admin can move from 
profile to profile making modifications, but what I think is happening 
is that the admin are not logging like they should and are instead 
simply Xing out. This means that those sessions may be used to set up 
unwanted objects and show links, and other varous forms of undesired 
information.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: html sitemap

2009-05-12 Thread Freddy Andersen

Creating a sitemap xml or html is just as easy as any other page...

In the controller pull the resources that are dynamic like

@pages = Pages.all

and then in the view do

% @pages.each do |page| %
%= link_to page.name, page_path(page) %
%end%

and then add the static stuff

% %w( page1 page2 ).each do |page| %
%= link_to page.name, some_path(page) %
%end%

how are your pages stored that you want in the site map?

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



[Rails] Re: How much data can be stored in the cookie?

2009-05-12 Thread Philip Hallstrom

 I've looked online, but I can't find a concrete answer to this. I'm
 considering storing some data in the user's cookie, to be accessed by
 javascript. It's not sensitive information, so security isn't a  
 problem.

 Altogether, I'm looking at two strings, one of which would be about  
 100
 characters long, and the other closer to 1000 or 1500. Is that too  
 much?


Now, how well all the browsers honor this I dunno, but I've always  
seen the 4k rule mentioned...

http://tools.ietf.org/html/rfc2965

5.3 Implementation Limits
Practical user agent implementations have limits on the number and  
size of cookies that they can store. In general, user agents' cookie  
support should have no fixed limits. They should strive to store as  
many frequently-used cookies as possible. Furthermore, general-use  
user agents SHOULD provide each of the following minimum capabilities  
individually, although not necessarily simultaneously:
* at least 300 cookies
* at least 4096 bytes per cookie (as measured by the characters that  
comprise the cookie non-terminal in the syntax description of the Set- 
Cookie2 header, and as received in the Set-Cookie2 header)
* at least 20 cookies per unique host or domain name User agents  
created for specific purposes or for limited-capacity devices SHOULD  
provide at least 20 cookies of 4096 bytes, to ensure that the user can  
interact with a session-based origin server.
The information in a Set-Cookie2 response header MUST be retained in  
its entirety. If for some reason there is inadequate space to store  
the cookie, it MUST be discarded, not truncated.
Applications should use as few and as small cookies as possible, and  
they should cope gracefully with the loss of a cookie.


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



[Rails] Re: How much data can be stored in the cookie?

2009-05-12 Thread pharrington

http://api.rubyonrails.org/classes/ActionController/Session/CookieStore.html:

This cookie-based session store is the Rails default. Sessions
typically contain at most a user_id and flash message; both fit within
the 4K cookie size limit. Cookie-based sessions are dramatically
faster than the alternatives.

On May 12, 5:33 pm, Philip Hallstrom phi...@pjkh.com wrote:
  I've looked online, but I can't find a concrete answer to this. I'm
  considering storing some data in the user's cookie, to be accessed by
  javascript. It's not sensitive information, so security isn't a  
  problem.

  Altogether, I'm looking at two strings, one of which would be about  
  100
  characters long, and the other closer to 1000 or 1500. Is that too  
  much?

 Now, how well all the browsers honor this I dunno, but I've always  
 seen the 4k rule mentioned...

 http://tools.ietf.org/html/rfc2965

 5.3 Implementation Limits
 Practical user agent implementations have limits on the number and  
 size of cookies that they can store. In general, user agents' cookie  
 support should have no fixed limits. They should strive to store as  
 many frequently-used cookies as possible. Furthermore, general-use  
 user agents SHOULD provide each of the following minimum capabilities  
 individually, although not necessarily simultaneously:
 * at least 300 cookies
 * at least 4096 bytes per cookie (as measured by the characters that  
 comprise the cookie non-terminal in the syntax description of the Set-
 Cookie2 header, and as received in the Set-Cookie2 header)
 * at least 20 cookies per unique host or domain name User agents  
 created for specific purposes or for limited-capacity devices SHOULD  
 provide at least 20 cookies of 4096 bytes, to ensure that the user can  
 interact with a session-based origin server.
 The information in a Set-Cookie2 response header MUST be retained in  
 its entirety. If for some reason there is inadequate space to store  
 the cookie, it MUST be discarded, not truncated.
 Applications should use as few and as small cookies as possible, and  
 they should cope gracefully with the loss of a cookie.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: belong to and search

2009-05-12 Thread pharrington

OK I'm dumb; you definitely don't need a virtual attribute for that
(not really sure what i was thinking), but its still ugly probably not
worth doing.

On May 12, 4:49 pm, pharrington xenogene...@gmail.com wrote:
 Yeah I deleted that post immediately after because that selects
 child.name. Something like :select = mothers.name AS mother_name
 would probably work, but just ugly AND then you'd need a mother_name
 virtual attribute in the Child model, making things rather needlessly
 horrific. I really can't think of a good way (without raw SQL) to do
 this in one query either.

 On May 12, 3:33 pm, Colin Law clan...@googlemail.com wrote:

  2009/5/12 pharrington xenogene...@gmail.com

   If you want to retrieve just the name, than use the :select option
   with your find:

   @children = Child.find(:all, :include = :mother, :select = 'name')

  Does that select child.name or mother.name?
  Colin

   On May 12, 11:04 am, Colin Law clan...@googlemail.com wrote:
2009/5/12 Anthony Ward rails-mailing-l...@andreas-s.net

 Hi thank you

 so if I use the include
 how do i just retrieve the name then

Do you mean you want a query finding the child, including the
mother.namebut not the other mother fields?  I do not know whether you
can do that.  I
think the overhead of fetching all columns is going to be rather small.
Colin

 example this is using the magic way

 @children do |child|

  ... print child.mother.name

 end

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



[Rails] Re: How much data can be stored in the cookie?

2009-05-12 Thread Chris Hanks

Thanks you two. I'd found the 4kb limit, but wasn't sure how that would 
come out in real-world usage - i.e., does Rails use up some of that 
space on its own, would the use of a secret and hash affect that... I 
also forgot to mention that I'm using Authlogic, which I believe would 
also take up some space.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Yet Another Time Zone Question

2009-05-12 Thread Jeremy Olliver

Hi,

The time zone is encoded in the string at the end e.g

Mon, 11 May 2009 18:24:37 +1200
Is in a time zone that's +12 (12 hours ahead of utc)
DateTime.parse or Time.parse will read this correctly.

So what you're doing is using a js date picker that gives you a string
like Mon May 11 18:24:37 2009
You just need to append the time zone difference to Mon May 11
18:24:37 2009 +1200 etc before parsing.

I handle storing dates in the db a little differently than you, but if
you know what you're doing don't worry about changing that part.
I usually store dates in the db in utc format (I think you can
configure this in environment.rb from memory), and you can easily set
the user's timezone in a filter in application controller
Time.zone = user.time_zone
which will handle all of the conversions for you.

Cheers,
Jeremy

On May 12, 10:57 am, Randall callmenanner...@gmail.com wrote:
 Seems like there should be an easy solution to this problem, yet I
 can't seem to find one.

 Here is the issue:
 How do you assign a time zone to a Time object that results from a
 parsed date/time string?

 Example:
 - I receive a date time string from a date picker widget that does not
 include time zone info (i.e. Mon May 11 18:24:37 2009).
 - Time zone for this date is known and may be different than what's
 local to the user
 - date/time is stored in the DB as unix time (i.e. 1242075962)
 - time zone is stored in the DB in tz format i(i.e. 'America/
 New_York')
 - I would like to be able to take a given date with its known time
 zone and calculate the equivalent unix time value.

  now = Time.now

 = Mon May 11 18:24:37 -0400 2009 now.to_i

 = 1242080677

  parsed = DateTime.parse(Mon May 11 18:24:37 2009)

 = Mon, 11 May 2009 18:24:37 + parsed.to_time

 = Mon May 11 18:24:37 UTC 2009 parsed.to_time.to_i
 = 1242066277
  Time.at 1242066277

 = Mon May 11 14:24:37 -0400 2009

 It seems there should be a way to append the time zone to the string
 before it is parsed or to associate the parsed time with a time zone
 (without converting the time to the zone), however I can't seem to
 find an answer.

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



[Rails] Re: html sitemap

2009-05-12 Thread Phlip

Freddy Andersen wrote:
 Creating a sitemap xml or html is just as easy as any other page...

Furtherless, I would not rip the routes.rb map to generate it, because such 
routes are either boring and static, like /app/faq, or are dynamically 
generated, like /blog/post/:name, and it's the interesting ones we need in the 
nav bar or site map. I would be interested to see if anyone can think of a 
clever way to do that by ripping the routes.rb map!

-- 
   Phlip
   http://flea.sourceforge.net/resume.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 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Apache / mod_rails config

2009-05-12 Thread giorgio

Hi,

I have mod_rails on Apache serving a rails app just fine.

What I want to do is have another folder served by apache as a
downloadable list of files.

Do I need to do mod_rewrite stuff and mess around with htaccess?

If so has anybody got a recipe?

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



[Rails] forms link css classes - not working

2009-05-12 Thread wejrow...@gmail.com

I used a scaffold to create an interface. I'm trying to style it and
I'm having trouble. In my css I have:


#content a, a:link, a:visited{
color: #ff8400;
}
#content a:hover{
background: #ff8400;
color: #FF;
}

#content a.urgent, a.urgent:link, a.urgent:visited {
color: #FF;
}
#content a.urgent:hover {
color: #FF;
background: #FF;
}

#content input.m_title{
  font-weight: bold;
  font-size: 28px;
  padding: 3px;
}


The style for the links works, but not for the .urgent class. Also the
style for the input.m_title will not work. When I view the source the
class is written right too:
a href=/galleries/1 style=urgentDestroy/a
and input style=m_title id=gallery_name name=gallery[name]
size=80 type=text value=Camp 09 /
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: forms link css classes - not working

2009-05-12 Thread Tom Z Meinlschmidt

hi,

a href=/galleries/1 style=urgent has to be
a href=/galleries/1 class=urgent

(style = class)

tom

wejrow...@gmail.com wrote:
 I used a scaffold to create an interface. I'm trying to style it and
 I'm having trouble. In my css I have:
 
 
 #content a, a:link, a:visited{
   color: #ff8400;
 }
 #content a:hover{
   background: #ff8400;
   color: #FF;
 }
 
 #content a.urgent, a.urgent:link, a.urgent:visited {
   color: #FF;
 }
 #content a.urgent:hover {
   color: #FF;
   background: #FF;
 }
 
 #content input.m_title{
   font-weight: bold;
   font-size: 28px;
   padding: 3px;
 }
 
 
 The style for the links works, but not for the .urgent class. Also the
 style for the input.m_title will not work. When I view the source the
 class is written right too:
 a href=/galleries/1 style=urgentDestroy/a
 and input style=m_title id=gallery_name name=gallery[name]
 size=80 type=text value=Camp 09 /
 

-- 
===
Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache
  - experienced RoR/PHP freelancer, available for hire

   www.meinlschmidt.com  www.maxwellrender.cz  www.lightgems.cz
===

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



[Rails] Re: forms link css classes - not working

2009-05-12 Thread wejrow...@gmail.com

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



[Rails] Re: [ANN/ADV] The Well-Grounded Rubyist now out in paperback

2009-05-12 Thread James Byrne

David A. Black wrote:
 Hello all --
 
 I'm delighted to announce that my new book The Well-Grounded Rubyist
 is now available in paperback (and still in PDF, of course). It's
 published by Manning, and it's in stock at the publisher[1] and 
 Amazon[2].

Arrived this morning on my desk.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] dynamic table names for AR models

2009-05-12 Thread Pete Hodgson

Hi All,

I have an interesting Active Record problem and I'm not quite sure what
the cleanest solution is. The legacy database that I am integrating with
has a strange wrinkle in its schema where one logical table has been
'partitioned' into several physical tables. Each table has the same
structure, but contains data about different items.

I'm not great at explaining this clearly (as you can tell!). Let me try
and explain with a concrete example. Let's say we have a Car, which has
one or more Wheels. Normally we'd represent that with a Car table and a
Wheels table like so:


CREATE TABLE cars (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(255),
  'etc
)


CREATE TABLE wheels (
  `id` int(11) NOT NULL auto_increment,
  `car_id` int(11) NOT NULL,
  `color` varchar(255),
  'etc
)

So far, so good. But with the 'partioning' strategy that is in my legacy
database it would look more like:

CREATE TABLE cars (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(255),
  'etc
)

CREATE TABLE car_to_wheel_table_map (
  `car_id` int(11) NOT NULL,
  `wheel_table` varchar(255)
)

CREATE TABLE wheels_for_fords (
  `id` int(11) NOT NULL auto_increment,
  `car_id` int(11) NOT NULL,
  `color` varchar(255),
  'etc
)

CREATE TABLE wheels_for_buicks (
  `id` int(11) NOT NULL auto_increment,
  `car_id` int(11) NOT NULL,
  `color` varchar(255),
  'etc
)

CREATE TABLE wheels_for_toyotas (
  `id` int(11) NOT NULL auto_increment,
  `car_id` int(11) NOT NULL,
  `color` varchar(255),
  'etc
)

So here we have a set of wheels_for_x tables, and a
car_to_wheel_table_map table which contains a mapping from car_id to the
specific wheels_for_x which contains the wheels for a specific car. If I
want to find the set of wheels for a car I first have to find out which
wheels table to use via the car_to_wheel_table_map table, and then look
up records in the wheel table specified in the car_to_wheel_table_map.

Firstly, can someone enlighten me as to if there is a standard name for
this technique?

Secondly, does anyone have any pointers on how I can make this work in
Active Record in a nice clean way. The way I see it I can either have a
Wheel model where the table name can be defined per instance, or I can
dynamically create Model classes at runtime with the correct table name
as specified in the mapping table.

Any advice gratefully received!

Cheers,
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 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Resource for creating a Text Editor (kinda like gmail or wordpress)

2009-05-12 Thread wejrow...@gmail.com

I'm looking to create a textarea that you can edit (bold, create
links, view html etc.), much like Wordpress or gmail.

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



[Rails] Re: dynamic table names for AR models

2009-05-12 Thread Gabriel Saravia


 Secondly, does anyone have any pointers on how I can make this work in
 Active Record in a nice clean way.

In a domain i'm workin in, this type of thing also came up, and I chose 
to split it in a somewhat similar way using abstract classes. Create an 
abstract class, Wheels, put all common code in there.  I chose to 
include the equivalent of that mapping table as a constant, so in your 
example a CarToWheelsClassHash Constant, and then create sub-classes 
for each of the wheels table.  Override the ActiveRecord Methods for the 
Wheel class, and then re-override them in the subclasses to bring them 
back.

Wheel  ActiveRecord::Base
  self.abstract_class = true

  CarToWheelsClassHash = {:ford = FordWheel}

  def self.abstract_find(car_brand, *normalfindargs)
CarToWheelsClassHash[car_brand].constantize.find(*normalfindargs)
  end

  [other code common to all wheels models]
end

FordWheel  Wheel
  code specific to the ford wheels model
end

hope that makes sense to you, i actually really like this solution so 
far on my end.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: dynamic table names for AR models

2009-05-12 Thread Pete Hodgson

Gabriel Saravia wrote:
 
 
 Wheel  ActiveRecord::Base
   self.abstract_class = true
 
   CarToWheelsClassHash = {:ford = FordWheel}
 
   def self.abstract_find(car_brand, *normalfindargs)
 CarToWheelsClassHash[car_brand].constantize.find(*normalfindargs)
   end
 
   [other code common to all wheels models]
 end
 
 FordWheel  Wheel
   code specific to the ford wheels model
 end
 
 hope that makes sense to you, i actually really like this solution so 
 far on my end.

Thanks Gabriel, but unfortunately this exact solution wouldn't work in 
our case. The names of the various Wheel tables are not known at design 
time. In other words, there's nothing to stop someone creating a new 
table and adding it to the mapping table during runtime.

Given the wonderful dynamic nature of ruby I suppose I could get past 
that fairly easily by creating the Wheel subclasses dynamically, but I'm 
not sure that that is the best approach.

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

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



  1   2   >