[Rails] Re: Apply style in collection_select ?????

2009-01-27 Thread Dharmdip Rathod

Thanks a lot ,
but it is not working here actually your suggested code is breaking my 
java script and style problem is still there , but never mind . Actually 
here this issue is looking some critical because i can not see html 
generated code in source when i write this

<%= collection_select(:customer, :country_id,
@countries, :id, :country, {:style => 'width:100px;', :onchange =>
"updateState('');", :id => 'country_id'}) %>

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: Merging array with same key - HELP

2009-01-27 Thread Shankar Ganesh

all the records should be included.


Julian Leviston wrote:
> Which record do you want to include for the repeated dates? the first,
> or last?
> 
> Julian
> 
> http://sensei.zenunit.com/
> http://random8.zenunit.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: Apply style in collection_select ?????

2009-01-27 Thread Julian Leviston

Hi,

Try this:

<%= collection_select(:customer, :country_id,  
@countries, :id, :country, {:style => 'width:100px;', :onchange =>  
"updateState('');", :id => 'country_id'}) %>

Argument list is:

name of instance variable (@customer becomes the symbol :customer),  
name of attribute (@customer.country_id becomes :country_id), then the  
array of objects (@countries), then the id method to send each of  
these (ie send them all "id" to get the id of each object), then the  
display method ("country" in this case, which seems a bit odd to me,  
it'd probably be name rather than country... ), then a HASH OBJECT  
(represented by {} braces) which has html options in it.

The html_options= simply assigns a temporary variable to be the  
hash... so you don't need it, because you're not using it elsewhere.

Good luck!

http://sensei.zenunit.com/
http://random8.zenunit.com/


On 28/01/2009, at 6:06 PM, Dharmdip Rathod wrote:

>
> Hi to all,
> i have this snip i want to apply style to this combo but there is no
> effect
> help...
>
> <%= collection_select(:customer,:country_id, @countries,:id, :country,
> html_options={ "style" => "width:110px" },:onchange =>
> 'updateState('');',:id =>'country_id' )%>
>
> 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: Merging array with same key - HELP

2009-01-27 Thread Julian Leviston

Which record do you want to include for the repeated dates? the first,  
or last?

Julian

http://sensei.zenunit.com/
http://random8.zenunit.com/

On 28/01/2009, at 1:50 PM, Shankar Ganesh wrote:

>
> Hi,
>
> I got a table like this
>
> ---
> id | what   | when  | color  |   to  | description |
> ---
> 1  | test   |01/01/2009 | red|04/01/2009 | hi this is test |
> ---
> 2  | test2  |02/01/2009 | green  |04/01/2009 | hi this is test |
> ---
> 3  | test3  |01/01/2009 | blue   |04/01/2009 | hi this is test |
> ---
> 4  | test4  |02/01/2009 | orange |04/01/2009 | hi this is test |
> ---
>
> I had fetch the value from the database in such a way like this
>
> ##
> #[JavaScript source with ROR]#
> ##
>
> var dAb = new Array();
> var x = 0;
> var event_task_today ='';
> var event_task ='';
>
> <% @eventall.each do |d| %>
> var DBdate1 = '<%= d.when%>';
> var eventdate1 = DBdate1.split('/');
> var task_date1 =eventdate1[2]+eventdate1[1]+eventdate1[0];
> dAb[x++] =  task_date1+"  style='background:<%=d.color%>;color:white;'><%= d.what%>";
> <% end %>
>
> If I alert 'dAb'value I'm getting like this
> *
>
> 20090101  style='background:red;color:white;'>test,20090102  align='left' style='background:green;color:white;'>test2, 
> 20090101
>  style='background:blue;color:white;'>test3,20090102  align='left' style='background:orange;color:white;'>test4
>
> I need to have JavaScript variable 'dAb'like this
>  
>
> 20090101  style='background:red;color:white;'>test style='background:blue;color:white;'>test3,20090102  align='left' style='background:green;color:white;'>test2 align='left' style='background:orange;color:white;'>test4
>
>  tag should be placed in between the values with same date ,date
> should be printed only once.
>
> PLEASE ADVICE.
>
> 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] Apply style in collection_select ?????

2009-01-27 Thread Dharmdip Rathod

Hi to all,
i have this snip i want to apply style to this combo but there is no
effect
help...

<%= collection_select(:customer,:country_id, @countries,:id, :country,
html_options={ "style" => "width:110px" },:onchange =>
'updateState('');',:id =>'country_id' )%>

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: Missing Image RoutingError = TOO SLOW

2009-01-27 Thread s.ross

Write a helper that wraps image_tag that checks to see whether you are  
on your production box. Iff you are on the production box, then  
image_tag it is, otherwise, some placeholder image guaranteed to be  
local in your images dir.

Will that work?

On Jan 27, 2009, at 10:27 PM, william.hard...@gmail.com wrote:

>
> My development setup gets its data from our production database, and
> this production database refers to a bunch of images that aren't
> available on my local machine, thus when running development I get a
> large number of Rails RoutingErrors, which I don't really mind.
>
> What I *do* mind is that catching every one of these errors takes
> about 2-4 seconds, even with my quad-core desktop.  If I try to load a
> page with 5 missing images, it will probably be 20 seconds before I
> can visit another page.
>
> Has anyone else experienced this and thought up a clever workaround?
> I had hoped that using
>
> rescue_from(ActionController::RoutingError) { |e| render :nothing =>
> true }
>
> in my application controller would fix it, but it just serves to make
> the exception not print out its text.  It still takes the regular
> amount of time per image for the exception to be caught and ignored.
>
> Thank you greatly for any insights into how I might improve this.
> Bill
> >


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



[Rails] Missing Image RoutingError = TOO SLOW

2009-01-27 Thread william.hard...@gmail.com

My development setup gets its data from our production database, and
this production database refers to a bunch of images that aren't
available on my local machine, thus when running development I get a
large number of Rails RoutingErrors, which I don't really mind.

What I *do* mind is that catching every one of these errors takes
about 2-4 seconds, even with my quad-core desktop.  If I try to load a
page with 5 missing images, it will probably be 20 seconds before I
can visit another page.

Has anyone else experienced this and thought up a clever workaround?
I had hoped that using

rescue_from(ActionController::RoutingError) { |e| render :nothing =>
true }

in my application controller would fix it, but it just serves to make
the exception not print out its text.  It still takes the regular
amount of time per image for the exception to be caught and ignored.

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



[Rails] javascript function needs rails variable

2009-01-27 Thread Rabia




document.getElementById('h').checked=true;
show_coords(<%= @pic_comments.to_json %>,"main",'<%=$domain%>/
users/update_picture_div',<%= @picture.id %>)

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



[Rails] Re: newbie question: types???

2009-01-27 Thread Steve H

Thanks Ryan and thortos!

I found a little more information that I was looking for here (as well
as at your links):

http://guides.rubyonrails.org/association_basics.html#_choosing_between_tt_belongs_to_tt_and_tt_has_one_tt

Cheers!

-Steve

On Jan 27, 12:57 pm, Ryan Bigg  wrote:
> There is documentation on the different field types 
> athttp://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/Ta...
>
> -
> Ryan Bigg
> Mocra - Premier iPhone and Ruby on Rails Consultants
> w -http://mocra.com
> e - ra...@mocra.com
> p - +61 432 937 289 or +61 7 3102 3237
> skype - radarlistener
>
> On 27/01/2009, at 7:04 PM, Steve H wrote:
>
>
>
> > Hello RoR veterans.
>
> > When looking at the following line in in the RoR getting started
> > guide:
>
> > script/generate scaffold Post name:string title:string content:text
>
> > My first thought was "Nice!! So they demo string and text. What are
> > the differences between these two, and what other types are
> > available?"
>
> > So far I've seen the following used in various tutorials and blogs:
> > string, text, integer, boolean, and references.
>
> > I just wish there were an actual *reference* page for this. Like
> > google made for the AppEngine API:
> >http://code.google.com/appengine/docs/python/datastore/typesandproper...
>
> > This (by the way) took me all of 60 seconds to find. I've been
> > searching for a similar guide in RoR all day and haven't found squat!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: ActiveRecord: Least surprise? Really?

2009-01-27 Thread Steve H

Philip, Robert, alberto, thanks for your replies!!  They all helped
and I do appreciate it.

It is making more sense now.

Cheers!

-Steve

On Jan 27, 5:15 pm, alberto  wrote:
> > When I create a "has_many" association, I would expect a fact table
> > "parent_child" to be created (with id, parent_id, and child_id
> > columns), and if I wanted a two-way relationship, I would add
> > "belongs_to" to the Child.
>
> I think you are getting your associations mixed up. In addition to the
> has_many and belongs_to associations, you can also have a
> has_and_belongs_to_many.
>
> to use that one you would do this:
>
> class User < ActiveRecord::Base
>   has_and_belongs_to_many :lists
> end
>
> class List < ActiveRecord::Base
>   has_and_belongs_to_many :users
> end
>
> and then you have a joining table, that if you stick to conventions,
> you call it:
> lists_users
> - user_id
> - list_id
>
> That is the simplest way to handle this, assuming you do not need to
> store any details about the membership.
>
> Now if you need to store more details about the membership, then you
> would have three classes: User, List and Membership
>
> class User < ActiveRecord::Base
>   has_many :memberships
> end
>
> class List < ActiveRecord::Base
>   has_many :memberships
> end
>
> class Membership < ActiveRecord::Base
>   belongs_to :user
>   belongs_to :list
> end
>
> Hope that helps. For the full API, go 
> to,http://rails.rubyonrails.com/classes/ActiveRecord/Associations/ClassM...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: I have many Rails 3.0 questions here....

2009-01-27 Thread Ryan Bigg

You will know on a need-to-know basis and right now you don't need to  
know. We can't give information if there's nothing else to share.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: RubyOnRails with MS SQL - Connectivity Error

2009-01-27 Thread Tony Puthenveettil

Hi Luke,

I installed deprecated-2.0.1.gem I have also installed the gem dbi-0.4.0 
and placed the ADO.rb file in the location :
\lib\ruby\site_ruby\1.8\DBD\ADO
and now I'm getting a different error as shown below:

* Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!
Unable to load driver 'ADO'
D:/Ruby/lib/ruby/site_ruby/1.8/dbi.rb:286:in `load_driver'
D:/Ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
D:/Ruby/lib/ruby/site_ruby/1.8/dbi.rb:236:in `load_driver'
D:/Ruby/lib/ruby/site_ruby/1.8/dbi.rb:154:in `_get_full_driver'
D:/Ruby/lib/ruby/site_ruby/1.8/dbi.rb:139:in `connect'
D:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/connection_adapters/sqlserver_adapter.rb:46:in
 
`sqlserver_connection'
D:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:292:in
 
`send'
D:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:292:in
 
`connection='
D:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:260:in
 
`retrieve_connection'


Awaiting your response again :)


Tony Puthenveettil wrote:
> Luke Pearce wrote:
>> iawgens had the answer - you need to install the deprecated gem
>> 
>> From a command prompt:
>> gem install deprecated
>> 
>> See here another person with the same issue
>> http://stackoverflow.com/questions/130547/setting-up-rails-to-work-with-sqlserver
> 
> Thanks a lot Luke... Let me try the same

-- 
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: Doing max of N tasks per given time

2009-01-27 Thread Ramon Tayag

Thanks, Greg.  I've taken a look.

I can have to Mailer models that have different uses: the first could
be for immediate emailing (forgot password, account activation, etc),
and the second, for less immediate email (site notifications,
newsletters, etc) which will be a subclass of ARMailer.

Ramon Tayag



On Wed, Jan 28, 2009 at 1:59 AM, Greg  wrote:
>
> You should look into AR Mailer:
>
> http://seattlerb.rubyforge.org/ar_mailer/
>
> The basic idea is that rather than actually sending emails, your app
> saves emails to the database.  AR Mailer then has an external script
> which can be used to send these emails in batches.
>
> Best of luck,
>
> Greg

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



[Rails] Re: I have many Rails 3.0 questions here....

2009-01-27 Thread Web Reservoir

I hope, many things will be cleared by next month.

I would also appreciate, if more information is shared here.

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: open_uri failure on good uri.

2009-01-27 Thread Don French

That worked perfectly. Thanks

Don

On Jan 27, 4:22 pm, Rob Biedenharn 
wrote:
> On Jan 27, 2009, at 8:35 PM, Don French wrote:
>
> > I am trying to open a URI using doc = Nokogiri::HTML(open(url)). I get
> > the following error:
>
> > URI::InvalidURIError: bad URI(is not URI?):
> >http://www.mauipropertytax.com/Datalets.asp?mnu=PSearch&submnu=Profil...
> > |1|*&item=1
> >        from /usr/local/ruby/lib/ruby/1.8/uri/common.rb:436:in `split'
> >        from /usr/local/ruby/lib/ruby/1.8/uri/common.rb:485:in `parse'
> >        from /usr/local/ruby/lib/ruby/1.8/open-uri.rb:29:in `open'
>
> > The problem is, if I paste the url in a browser it does go to the
> > proper page.  What am I missing
>
> Try replacing the | characters with %7C
>
> Or try:
>
> doc = Nokogiri::HTML(open(URI.encode(url)))
>
> -Rob
>
> Rob Biedenharn          http://agileconsultingllc.com
> r...@agileconsultingllc.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to share tables between Ruby Apps...

2009-01-27 Thread Mohit Sindhwani

LaughingNinja wrote:
> Hi,
>
> We are in the process of rewriting our intranet applications in Ruby.
> We have one complete that requires an email invite being sent. We want
> to write another app that simply looks for unsent emails and sends
> them. This will be used by several ruby apps. How can we share this
> table(email details) across several Ruby apps?
>
> Thanks,
> GARY LACKERMAN
> Software Developer
>   
You could create a message queue in a shared database of some sort.  All 
applications insert their "to send" emails into the message queue 
(database table) and a regular job starts up and reads in the details 
and tries to send them.  If it manages to send it, it cleans up for this 
record (i.e, deletes the item from the table and/ or informs someone).  
If it doesn't manage to send the email, it increments some sort of 
"retry count" in the database and waits again.  If a message fails to go 
after a certain number of tries, it simply marks the message as 
undeliverable and removes it from the message queue to a "failed items" 
database.

Now, I wonder if there is a message queue implementation in Ruby that 
does this?

Cheers,
Mohit.
1/28/2009 | 11:50 AM.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: Login form_tag with select_tag option

2009-01-27 Thread Tony Puthenveettil

Frederick Cheung wrote:
> On 27 Jan 2009, at 11:52, Tony Puthenveettil wrote:
> 
>>
>> Hi all,
>> In the application i develop, a sophisticated login system is  
>> required.
>> Being a newbie in Ruby, i'm not comfortable with the select tag in the
>> form tag.
> 
>>
>> Could anybody please give me a better snippet to accomplish the  
>> same...?
>>
> have a look at the (still in progress) guide on forms 
> http://guides.rails.info/form_helpers.html
> 
> Fred

Thanks a lot Frederick... I was looking for a simple logic. However it 
must work.
-- 
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: request.env variables in an observer

2009-01-27 Thread alberto

> I have a scenario were I would like to inject the IP address and
> UserAgent into an email when a database record is saved.

You need to trap the remote_ip and user_agent from the request method
in the Controller instance for that request. That is where this
information is received. Then you need to have this information
available in the Active Record instance where the save is happening.

One way to do this is to use the Thread class since both operations
are ocurring on the same thread. There is a Thread.current object that
you can stuff the info you need.

In your application.rb controller file:

class ApplicationController < ActionController::Base
  before_filter :log_ips

  private

  def log_ips
Thread.current['remote_ip'] = request.remote_ip
Thread.current['user_agent'] = request.user_agent
  end

end

Then somewhere your rails load path, either in lib or your models
directory, add an active record extension.

module ArExtension
  def self.included(m)
m.class_eval do
  after_save :log_ips
end
  end

  def log_ips
puts Thread.current['user_agent'] # do you really want to email
every request? you might want to do something else
puts Thread.current['remote_ip']
  end

end

ActiveRecord::Base.class_eval do
  include ArExtension
end

Hope that helps.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: Merging array with same key - HELP

2009-01-27 Thread Shankar Ganesh

Hi,

I got a table like this

---
id | what   | when  | color  |   to  | description |
---
1  | test   |01/01/2009 | red|04/01/2009 | hi this is test |
---
2  | test2  |02/01/2009 | green  |04/01/2009 | hi this is test |
---
3  | test3  |01/01/2009 | blue   |04/01/2009 | hi this is test |
---
4  | test4  |02/01/2009 | orange |04/01/2009 | hi this is test |
---

I had fetch the value from the database in such a way like this

##
#[JavaScript source with ROR]#
##

var dAb = new Array();
var x = 0;
var event_task_today ='';
var event_task ='';

<% @eventall.each do |d| %>
 var DBdate1 = '<%= d.when%>';
 var eventdate1 = DBdate1.split('/');
 var task_date1 =eventdate1[2]+eventdate1[1]+eventdate1[0];
 dAb[x++] =  task_date1+" <%= d.what%>";
<% end %>

If I alert 'dAb'value I'm getting like this
 *

20090101 test,20090102 test2,20090101 
test3,20090102 test4

I need to have JavaScript variable 'dAb'like this
  

20090101 testtest3,20090102 test2test4

 tag should be placed in between the values with same date ,date 
should be printed only once.

PLEASE ADVICE.

Thanks in advance.

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

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



[Rails] Re: Plugin Module Help

2009-01-27 Thread Mark Reginald James

Nate Leavitt wrote:

> Is that multi-thread safe for the newer versions of rails?

Yes.

-- 
Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.com

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



[Rails] Re: Merging array with same key - HELP

2009-01-27 Thread Shankar Ganesh

Hi,

   I got a table like this


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

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



[Rails] Re: open_uri failure on good uri.

2009-01-27 Thread Rob Biedenharn

On Jan 27, 2009, at 8:35 PM, Don French wrote:
> I am trying to open a URI using doc = Nokogiri::HTML(open(url)). I get
> the following error:
>
> URI::InvalidURIError: bad URI(is not URI?):
> http://www.mauipropertytax.com/Datalets.asp?mnu=PSearch&submnu=Profile&pin=39035095&tp=2&cp=1&State=1
>  
> |1|*&item=1
>from /usr/local/ruby/lib/ruby/1.8/uri/common.rb:436:in `split'
>from /usr/local/ruby/lib/ruby/1.8/uri/common.rb:485:in `parse'
>from /usr/local/ruby/lib/ruby/1.8/open-uri.rb:29:in `open'
>
> The problem is, if I paste the url in a browser it does go to the
> proper page.  What am I missing

Try replacing the | characters with %7C

Or try:

doc = Nokogiri::HTML(open(URI.encode(url)))

-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: Merging array with same key - HELP

2009-01-27 Thread Shankar Ganesh

hi,
   Thank you DUDE it works !

Harold wrote:
> Hi,
> 
> hash = {}
> array1.uniq.each { |d| hash[d] = [] }
> array1.each_with_index { |x,i| hash[x] << array2[i] }
> hash.each_key { |key| hash[key] = hash[key].join('-') }
> hash.inspect # => {"01/01/2009"=>"1stjan1-1stjan2-1stjan3",
> "10/01/2009"=>"10thjan1-10thjan2"}
> 
> Enjoy,
> 
> -Harold
> On Jan 27, 2:13�am, Shankar Ganesh 

-- 
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: changing model type

2009-01-27 Thread Mark Reginald James

Jared Moody wrote:
> I have a form that allows a User to add/edit the additional Users or
> LoginUsers to/on their account, but the wrong validations are run when
> updating a User to be a Login user or vice-versa.
> ...
> # revoking login privledges
> if @user.is_a?(LoginUser) && !params[:allow_login]
>   #switch the type here, tried a few different things but none work
>   @user[:type] = "User"
 @user.save_without_validation!
 @user = User.find(@user.id)
> end

Try adding the above two lines.

-- 
Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.com

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



[Rails] Re: How to share tables between Ruby Apps...

2009-01-27 Thread alberto

> How can we share this
> table(email details) across several Ruby apps?

Sharing a table is straight forward. If they are in the same database,
you simply call the class methods for this utility functionality. If
the table exists in another database, you add that database to the
database.yml file.

More importantly however, you want to avoid code duplication. You do
not want to duplicate the code that looks for unsent emails in all
your apps. You have several options. The first ones that come to mind
are:

1. Write a utility rails app that does the looking for unsent emails
and sending. All your other apps simply write to the table that stores
these unsent emails. With this approach you can build views that allow
you to see the queue, etc of all the emails, regardless of the app.

2. If you prefer to have the methods available in each app, then you
want to look at the plugins facility in rails. You can write a plugin
that gets used by all your apps. Then each of your apps gets the
plugin from the same repository.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: ajax search feature works in FF but not IE

2009-01-27 Thread Mark Reginald James

Pardee, Roy wrote:

> <%= observe_field('project_search',
> :url => { :controller => "projects", :action => "index_search"},
> :update => "project-list", 
> ...
> That partial renders a table w/one row per project.  This works just fine 
> from FireFox.  But from IE I don't get my table--just a blank page.  So the 
> records that used to be in my table id="project-list" are gone, but I don't 
> see the new ones that index_search queried out of the db.  Judging from the 
> log, IE is indeed making the request to index_search, passing the params it 
> should, etc.  The log even says, e.g.,
> ...
> But IE doesn't seem to want to actually *display* these guys.  FF's web 
> development toolbar tells me I'm in "standards compliance mode" when I pull 
> up a searched list of projects, so I believe the markup is all kosher.


:update changes the innerHTML of a node, so you will be inserting
the table inside the table tag.

Wrap a div around the table and update that instead.

-- 
Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.com

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



[Rails] Re: Creating records with file upload in migration

2009-01-27 Thread alberto

> I have a migration which creates several records along with the table.
> eg
> Forum.create :title => "General Discussion", :description => "General
> Chit-Chat"

I am not sure you want to combine migrations with record creation. It
is probably best for you to handle this via a load script or a rake
task.

As to the file upload, if you are using a plugin like attachment_fu,
then you are all set. Take a look at the plugin tests directory to see
how those simulate the upload of files and create the uploaded files
either in the db or in the path you specified in your models.


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



[Rails] how to delete temp files

2009-01-27 Thread anton effendi
Haii..
any body can help me?? I want to delete temp file.. in controller.. can help
me please...???

thank you.





-- 
Wu You Duan

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



[Rails] open_uri failure on good uri.

2009-01-27 Thread Don French

I am trying to open a URI using doc = Nokogiri::HTML(open(url)). I get
the following error:

URI::InvalidURIError: bad URI(is not URI?):
http://www.mauipropertytax.com/Datalets.asp?mnu=PSearch&submnu=Profile&pin=39035095&tp=2&cp=1&State=1|1|*&item=1
from /usr/local/ruby/lib/ruby/1.8/uri/common.rb:436:in `split'
from /usr/local/ruby/lib/ruby/1.8/uri/common.rb:485:in `parse'
from /usr/local/ruby/lib/ruby/1.8/open-uri.rb:29:in `open'

The problem is, if I paste the url in a browser it does go to the
proper page.  What am I missing


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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 pass current value of form field in link_to?

2009-01-27 Thread John Yerhot

Glad it worked for you.
:)

On Jan 27, 3:47 pm, Joe Peck  wrote:
> John Yerhot wrote:
> >> <%= link_to "Preview Post", {:action => :preview, :id => @topic.id,
> >> :body => @body}, {:id => 'link', :target => "_blank"} %>
>
> > try this:
>
> > <%= link_to "Preview Post", {:action => :preview, :id => @topic.id},
> > {:onclick => "this.href +='?body='+encodeURIComponent($F
> > ('id_of_the_form_element')); return true", :id => 'link', :target =>
> > "_blank"} %>
>
> Muchas gracias, that is close to perfect.  The only problem is if I hit
> "Preview Post" multiple times, it keeps adding onto body, but I can fix
> that problem.
>
> It's times like these that I realize I need to learn more javascript.
> --
> 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: ruby regular expression issue matching

2009-01-27 Thread Me

doh.  I do that in the rest of the expression, duh..   Thanks.  Mind
fart I guess.

On Jan 27, 7:15 pm, Philip Hallstrom  wrote:
> > I have something like this to match:
>
> > /\/s-#{slot}\/p-#{port}\/sts-#{sts}/
>
> > The problem is the variable STS if it is a 1 matches on 1,10,11,12,13
> > and so on.
>
> > How do I get it to match only the value and nothing sles?
>
> What follows the sts portion in your string?  Is it something like  
> "sts-123-foo" or "sts-123?foo" or something?  You need to figure out  
> what that character is and then add it to the regular expression.  Or  
> if it's nothing and that's the end of the line anchor it with '$'.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] ajax search feature works in FF but not IE

2009-01-27 Thread Pardee, Roy

Hey All,

I put a simple search box on my projects/index view, via the following 
observe_field call:

<%= observe_field('project_search',
:url => { :controller => "projects", :action => "index_search"},
:update => "project-list", 
:loading => "Element.show('search_spinner')",
:complete => "Element.hide('search_spinner')",
:frequency => 1,
:submit => 'search') -%>

The index_search action queries out the proper set of projects & renders the 
list to a partial, like so:

def index_search
  min_query_length = 1
  q = params[:project_search]

  if q.length > min_query_length then
@projects = Project.find_by_name_fragment(q) || []
  else
order_by = params[:order_by] || 'statuses.name'
@projects = Project.find(:all, :order => order_by, :include => 'status')
  end
  respond_to do |format|
format.js do
  render :partial => "project_list.html.erb"
end
  end
end

That partial renders a table w/one row per project.  This works just fine from 
FireFox.  But from IE I don't get my table--just a blank page.  So the records 
that used to be in my table id="project-list" are gone, but I don't see the new 
ones that index_search queried out of the db.  Judging from the log, IE is 
indeed making the request to index_search, passing the params it should, etc.  
The log even says, e.g.,

  Rendered projects/_project (0.01600)
  Rendered projects/_project_list.html.erb (0.10900)

But IE doesn't seem to want to actually *display* these guys.  FF's web 
development toolbar tells me I'm in "standards compliance mode" when I pull up 
a searched list of projects, so I believe the markup is all kosher.

What am I doing wrong?

Thanks!

-Roy

Roy Pardee
Research Analyst/Programmer
Group Health Center For Health Studies (Cancer Research Network)
(206) 287-2078
Google Talk: rpardee

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: ruby regular expression issue matching

2009-01-27 Thread Philip Hallstrom

> I have something like this to match:
>
> /\/s-#{slot}\/p-#{port}\/sts-#{sts}/
>
> The problem is the variable STS if it is a 1 matches on 1,10,11,12,13
> and so on.
>
> How do I get it to match only the value and nothing sles?

What follows the sts portion in your string?  Is it something like  
"sts-123-foo" or "sts-123?foo" or something?  You need to figure out  
what that character is and then add it to the regular expression.  Or  
if it's nothing and that's the end of the line anchor it with '$'.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: ActiveRecord: Least surprise? Really?

2009-01-27 Thread alberto

> When I create a "has_many" association, I would expect a fact table
> "parent_child" to be created (with id, parent_id, and child_id
> columns), and if I wanted a two-way relationship, I would add
> "belongs_to" to the Child.

I think you are getting your associations mixed up. In addition to the
has_many and belongs_to associations, you can also have a
has_and_belongs_to_many.

to use that one you would do this:

class User < ActiveRecord::Base
  has_and_belongs_to_many :lists
end

class List < ActiveRecord::Base
  has_and_belongs_to_many :users
end

and then you have a joining table, that if you stick to conventions,
you call it:
lists_users
- user_id
- list_id

That is the simplest way to handle this, assuming you do not need to
store any details about the membership.

Now if you need to store more details about the membership, then you
would have three classes: User, List and Membership

class User < ActiveRecord::Base
  has_many :memberships
end

class List < ActiveRecord::Base
  has_many :memberships
end

class Membership < ActiveRecord::Base
  belongs_to :user
  belongs_to :list
end

Hope that helps. For the full API, go to,
http://rails.rubyonrails.com/classes/ActiveRecord/Associations/ClassMethods.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] ruby regular expression issue matching

2009-01-27 Thread Me

I have something like this to match:

/\/s-#{slot}\/p-#{port}\/sts-#{sts}/

The problem is the variable STS if it is a 1 matches on 1,10,11,12,13
and so on.

How do I get it to match only the value and nothing sles?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: Right way to do

2009-01-27 Thread Philip Hallstrom

> What is the right way to print localizations?
>
> <%=t :User %> OR <%=t "User" %> OR <%=t ("User") %>
>
> <%=t :User %> works fine, but <%=t :User.Username %> doesn't, but this
> works:
> <%=t ("User.Username") %>

I'd go with <%=t "User" %>.

:User works in this case because t() is converting the argument to a  
string and :User.to_s => "User".  :User.Username won't work because  
there is no "Username" method on the *symbol* "User".

-philip

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



[Rails] Re: ActiveRecord: Least surprise? Really?

2009-01-27 Thread Robert Walker

Steve H wrote:
> Could someone set my thinking straight here?  Maybe I just need a
> little explanation around best practices or something

I'm having trouble following your logic.

Parent < ActiveRecord::Base
  has_many :children
end

Child < ActiveRecord::Base
  belongs_to :parent
end

A parent has many children and each child belongs to one a parent.

parent = Parent.find_by_name("Bill")
parent.children.count
=> 0
parent.children.build(:name => "Steve");
parent.children.count
=> 1
steve = parent.children.find_by_name("Steve")
steve.name
=> Steve

Database:
--
parents
|id|name|
|1|Bill|

children
|id|parent_id|name|
|id|1|Steve|

It all make perfect sense to me.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Extending AR to write audit columns

2009-01-27 Thread James Byrne

Robert Walker wrote:
> James Byrne wrote:
>> Any suggestions as to what I am doing wrong?
> 
> Sorry this isn't a direct answer to your question, but I just wanted to 
> ask if you have looked at any of the existing auditing plugins to see if 
> they support your needs?
> 
> For example:
> http://github.com/collectiveidea/acts_as_audited/tree/master

Despite the similarity of nomenclature, what I wish to do is different 
than the service provided by that plugin, or acts_as_versioned, etc. 
The example code given above is a minimalist representation of my 
situation.

I have since read that the technique I am trying to employ has been 
broken by a change to Rails (http://dev.rubyonrails.org/changeset/7749) 
but I have been unable to discover a working alternative.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] How to share tables between Ruby Apps...

2009-01-27 Thread LaughingNinja

Hi,

We are in the process of rewriting our intranet applications in Ruby.
We have one complete that requires an email invite being sent. We want
to write another app that simply looks for unsent emails and sends
them. This will be used by several ruby apps. How can we share this
table(email details) across several Ruby apps?

Thanks,
GARY LACKERMAN
Software Developer

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



[Rails] acts as indexed suitable?

2009-01-27 Thread Mike C

I'm using the acts as indexed to sort of implement a full text search
for titles of stories. This is working perfectly, but it seems it
stores these indexes in files. This worries me since I fear there may
be a lot of IO which could be slow since it doesn't seem to scale. Any
comments on this are appreciated. 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] changing model type

2009-01-27 Thread Jared Moody

I have a form that allows a User to add/edit the additional Users or
LoginUsers to/on their account, but the wrong validations are run when
updating a User to be a Login user or vice-versa.

For more clarity (with only one case shown):

class User < ActiveRecord::Base
end

class LoginUser < User
  validates_presence_of :login
  validates_presence_of :password
end

class UsersController < ApplicationController
  ...
  def update
@user = @account.users.find(params[:id])

# revoking login privledges
if @user.is_a?(LoginUser) && !params[:allow_login]
  #switch the type here, tried a few different things but none work
  @user[:type] = "User"
end

if @user.update_attributes(params[:user])
  flash[:notice] = 'User successfully updated.'
  redirect_to(edit_account_path)
else
  # edit action rendered with errors on login and password
  render :action => "edit"
end

  end
  ...
end

Can someone help me solve this?

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: How to add fields dynamically?

2009-01-27 Thread Phlip

Aa Sh wrote:
> I would like have a simple interface for users to add data into
> database. How to add new textareas in form, until user want it and
> submit all of them at once?

Look up how to serialize a Hash into a :text field.

If you don't need to query a database by a field, you don't need the full 
overhead of a field type. To give your users abstract data, let them enter keys 
and values into fields that expand forever, and then AR will serialize them. 
They go in as YAML strings of your hashes.

-- 
   Phlip


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



[Rails] Re: How to add fields dynamically?

2009-01-27 Thread Peter De Berdt

On 28 Jan 2009, at 00:13, Aa Sh wrote:

> I would like have a simple interface for users to add data into
> database. How to add new textareas in form, until user want it and
> submit all of them at once?

http://railscasts.com/episodes/73-complex-forms-part-1
http://railscasts.com/episodes/74-complex-forms-part-2
  ... and everything on railscasts.com basically


Best regards

Peter De Berdt


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



[Rails] Re: Absolute image URL?

2009-01-27 Thread Rob Biedenharn

On Jan 27, 2009, at 4:06 PM, Sven wrote:

>
> On Jan 27, 3:57 pm, Rob Biedenharn 
> wrote:
>> Try image_url rather than image_path
>
> Sadly that method does not seem to exist (at least not in
> ActionView::Helpers::AssetTagHelper or in the Rails API docs). I wish
> it did!
>
> -Sven


So write one!  (or try this untested one)

def image_url(source)
   abs_path = image_path(source)
   unless abs_path =~ /\Ahttp/
 abs_path = "http#{'s' if https?}://#{host_with_port}/#{abs_path}"
   end
   abs_path
end

Put it in a helper such as app/helpers/application_helper.rb

-Rob

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



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



[Rails] Re: How to add fields dynamically?

2009-01-27 Thread Phlip

Aa Sh wrote:
> I would like have a simple interface for users to add data into
> database. How to add new textareas in form, until user want it and
> submit all of them at once?

However, if you _do_ need to look these strings up in the database, you need a 
child table with a parent_id, and key and value fields!


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



[Rails] newbie testing: xml_http_request and route, route not recognised

2009-01-27 Thread itsastickup

In my view the generated html has this, and it works just fine:

delete

So in my functional tests I tried the following and it tells me the
action isn't recognized, as if it isn't translating the :delete method
to the destroy action in the controller :

xml_http_request :delete, person_movie_path(movies
(:one).person_id,movies(:one).id)

"rake test" gets me :

test_delete(MoviesControllerTest):
ActionController::UnknownAction: No action responded to /people/
520095529/movies/953125641. Actions: create, create_guid
, delete_more_than, destroy, edit, edit_person_movie_path, exception,
exception=, index, log_for_stats, log_login, new,
redirect_loop_or_default, referrer_url, rescue_action_without_handler,
save_referrer_to_cookie, store_loop, and update


I'm a bit perplexed. googling didn't get me any clues. The route is
correct, I think. See this pastie  http://www.pastie.org/372719 if you
think my movie routes may be up the spout.

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



[Rails] How to add fields dynamically?

2009-01-27 Thread Aa Sh

I would like have a simple interface for users to add data into
database. How to add new textareas in form, until user want it and
submit all of them at once?
-- 
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: javascript and caching

2009-01-27 Thread Frederick Cheung


On 27 Jan 2009, at 22:19, jonh...@gmail.com wrote:
>
> My question is, I really must do everything on ajax?
>
> Lets say if I call myapp.com/projects and projects use all those js
> files, then I click on a "show" link and I'm redirected to myapp.com/
> projects/1 on this redirect, all js will be reloaded again?
>
Not necessarily - if your web server is serving the JS files with the  
correct caching headers then the browser shouldn't reload them (and  
using gzip encoding will make a big difference too).

Fred
> Whats the best way to handle with javascript and caching?
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: Extending AR to write audit columns

2009-01-27 Thread Robert Walker

James Byrne wrote:
> Any suggestions as to what I am doing wrong?

Sorry this isn't a direct answer to your question, but I just wanted to 
ask if you have looked at any of the existing auditing plugins to see if 
they support your needs?

For example:
http://github.com/collectiveidea/acts_as_audited/tree/master

-- 
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] javascript and caching

2009-01-27 Thread jonh...@gmail.com

Hi guys,

I'll start to develop a new app that uses some heavy js librarys
(prototype, scriptaculous, tinymce and so on).

Someone told me to make all the app using ajax, so all the js files
will be loaded only once.

My question is, I really must do everything on ajax?

Lets say if I call myapp.com/projects and projects use all those js
files, then I click on a "show" link and I'm redirected to myapp.com/
projects/1 on this redirect, all js will be reloaded again?

Whats the best way to handle with javascript and caching?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: redirect_to problem .. caching?

2009-01-27 Thread Brian Morearty

Hi gang,

I had the same problem.  I've just figured out the fix.  Use:

  redirect_to :action => :symbol

instead of

  redirect_to :action => 'string'

Then the flash message is shown.

Too bad you have to remember that distinction, though.  That shouldn't 
be necessary.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: How to pass current value of form field in link_to?

2009-01-27 Thread Joe Peck

John Yerhot wrote:
>> <%= link_to "Preview Post", {:action => :preview, :id => @topic.id,
>> :body => @body}, {:id => 'link', :target => "_blank"} %>
> 
> try this:
> 
> <%= link_to "Preview Post", {:action => :preview, :id => @topic.id},
> {:onclick => "this.href +='?body='+encodeURIComponent($F
> ('id_of_the_form_element')); return true", :id => 'link', :target =>
> "_blank"} %>

Muchas gracias, that is close to perfect.  The only problem is if I hit 
"Preview Post" multiple times, it keeps adding onto body, but I can fix 
that problem.

It's times like these that I realize I need to learn more javascript.
-- 
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] saving ActiveRecord/Form data changes??

2009-01-27 Thread Bill Butler

Greetings everyone,

This post has been moved (on suggestion) from the Ruby forum.

I can't pass updated/changed values from the form elements to the
ActiveRecord.  However something is going through because the table's
update_when column is registering the date/time of the update, but
otherwise no data revisions to other columns transpire.  Have tried
using form_for helper as well, but the same results.

This is all new to me, so not sure what additional info will be
relevant.  But am using Ruby 1.8.6 with a local MYSQL 5.1 database thru
a Radrails IDE.  My apologies for whatever info I have ommitted.  Any
suggestions on where I have gone astray will be most appreciated.

Thanks, Bill


CONTROLLER:

class FileController < ApplicationController

def edit
@file = File.find(params[:id])
end

def update
@file = File.find(params[:id])
if @file.update_attributes(params[:file])
redirect_to :action => 'show', :id => @file
else
render :action => 'edit'
end
end
end

VIEW:

<% form_tag (:action => 'update', :id => @file.id) do %>

Description
<%= text_area 'file', 'description' 

<%= submit_tag 'Save changes' %>
<% end %>

<%= link_to 'Back', {:action => 'list'} %>
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: How to pass current value of form field in link_to?

2009-01-27 Thread John Yerhot

> <%= link_to "Preview Post", {:action => :preview, :id => @topic.id,
> :body => @body}, {:id => 'link', :target => "_blank"} %>

try this:

<%= link_to "Preview Post", {:action => :preview, :id => @topic.id},
{:onclick => "this.href +='?body='+encodeURIComponent($F
('id_of_the_form_element')); return true", :id => 'link', :target =>
"_blank"} %>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: Absolute image URL?

2009-01-27 Thread Sven

On Jan 27, 3:57 pm, Rob Biedenharn 
wrote:
> Try image_url rather than image_path

Sadly that method does not seem to exist (at least not in
ActionView::Helpers::AssetTagHelper or in the Rails API docs). I wish
it did!

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



[Rails] Re: newbie question: types???

2009-01-27 Thread Ryan Bigg

There is documentation on the different field types at 
http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/Table.html#M001780

-
Ryan Bigg
Mocra - Premier iPhone and Ruby on Rails Consultants
w - http://mocra.com
e - ra...@mocra.com
p - +61 432 937 289 or +61 7 3102 3237
skype - radarlistener








On 27/01/2009, at 7:04 PM, Steve H wrote:

>
> Hello RoR veterans.
>
> When looking at the following line in in the RoR getting started
> guide:
>
> script/generate scaffold Post name:string title:string content:text
>
> My first thought was "Nice!! So they demo string and text. What are
> the differences between these two, and what other types are
> available?"
>
> So far I've seen the following used in various tutorials and blogs:
> string, text, integer, boolean, and references.
>
> I just wish there were an actual *reference* page for this. Like
> google made for the AppEngine API:
> http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html
>
> This (by the way) took me all of 60 seconds to find. I've been
> searching for a similar guide in RoR all day and haven't found squat!
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: Absolute image URL?

2009-01-27 Thread Rob Biedenharn

On Jan 27, 2009, at 2:53 PM, Sven wrote:
> I'm generating an XML feed to be used from outside of a Rails
> application. The feed should include URLs for associated images. I'm
> using image_path to generate the image URLs. This respects
> relative_url_root, but all it gives me is the absolute path of the
> image relative to the domain root (e.g. /image_assets/1234/
> my_image.jpg). Is there a standard way to get fully specified absolute
> URLs to images? I looked at url_for, which implements an :only_path
> option, but that option is only available for controller paths.
>
> Thanks,
>
> Sven


Try image_url rather than image_path

-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: German letter ä, ö, ü in rf pdf

2009-01-27 Thread Codeblogger
Hi Adam,

have a look at Prawn (http://prawn.majesticseacreature.com/) and Prawnto (
http://www.cracklabs.com/prawnto).
Works great for me...

Regards
Nicolai

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



[Rails] German letter ä, ö, ü in rfpdf

2009-01-27 Thread Adam Meyer

Hi,

I need PDF creation in Rails and decided for RFPDF.
Everything works quite nice the only problem is that I can't display
ä,ö,ü in the pdf documents.

I found a tutorial that says that I have to create a font config file
with MakeFont.

I did it, but now I don't now where to put al this files.

Does anyone has experience with creating PDFs in Rails with ä,ü,ö
letters?

Thx

Adam
-- 
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: User Permalink in Rails ???

2009-01-27 Thread Brian Hogan

If you do
> map.connect ':username', :controller => "users" , :action => "show"

you'll need to look for params[:username] instead of params[:id] when
you look up the record.


On Mon, Jan 26, 2009 at 9:13 PM, Ryan Bigg  wrote:
>
> map.connect ':username', :controller => "users" , :action => "show"
>
> At the bottom of your routes.rb file.
> -
> Ryan Bigg
>
>
>
>
>
>
>
> On 27/01/2009, at 1:07 PM, Louis-Pierre Dahito wrote:
>
>>
>>
>>
>> Brian Hogan wrote:
>>> LOL
>>> There's no reason to use to_param.  It's just a convention to pass
>>> the
>>> id through the URL. It's type is not enforced.
>>>
>>> # expects /users/15
>>> def edit
>>>  @user = User.find(params[:id])
>>> end
>>>
>>> # expects /users/bphogan
>>> def show
>>>  @user = User.find_by_username(params[:id])
>>> end
>>>
>>> The only thing to watch out for is that find throws a RecordNotFound
>>> exception when there is no record found, which will display a 404 in
>>> production, and find_by_username returns nil, so you'll wanna handle
>>> that.
>>>
>>> But there's no need to do anything funny with to_params or routing or
>>> anything like that.
>>
>> Thx a lot but I really do want to get rid of the /user before
>> "username"
>> so my url looks like this: http://mydomain.com/username... like i said
>> before...
>> http://twitter.com/gigaom for instance... How do i get rid of
>> "user/" in
>> the url 
>>
>> thx again
>> --
>> 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: ActiveRecord: Least surprise? Really?

2009-01-27 Thread Phlip


> If I wanted to create a class that maintains various user lists:
> class UserLists < ActiveRecord::Base
>   has_many :naughty, :class => "User"
>   has_many :nice, :class => "User"
>   has_many :absent, :class => "User"
> end
> 
> I would expect some fact tables to be created: naughty_users (with
> columns id, userlist_id, user_id), nice_users (with id, userlist_id,
> user_id), and absent_users (again with id, userlist, and id).

has_many :foo, :class => 'User' only says "find a model called User, and expect 
it to have a user_list_id pointing to us".

To distinguish moral relevance, use:

   has_many :naughty, :class => 'User', :conditions => { :morality => 'naughty }

Less mind-reading on AR's part - it was not going to guess that User.naughty 
had 
a relationship with UserList#naughty, unless you specify that.

-- 
   Phlip


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



[Rails] Absolute image URL?

2009-01-27 Thread Sven

I'm generating an XML feed to be used from outside of a Rails
application. The feed should include URLs for associated images. I'm
using image_path to generate the image URLs. This respects
relative_url_root, but all it gives me is the absolute path of the
image relative to the domain root (e.g. /image_assets/1234/
my_image.jpg). Is there a standard way to get fully specified absolute
URLs to images? I looked at url_for, which implements an :only_path
option, but that option is only available for controller paths.

Thanks,

Sven
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
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 pass current value of form field in link_to?

2009-01-27 Thread Joe Peck

Man, maybe I am making this more complicated than it should be.

I just need to pass whatever is in the text_field to a "preview" action 
when I click a "preview" link.  So I don't really need to dynamically 
update anything, but when "preview" is clicked, I want to get what is in 
the text_field and pass it to my "preview" action.

To make it clearer, when someone clicks "Preview Post", I want @body to 
be set to whatever is in the text_field.
<%= link_to "Preview Post", {:action => :preview, :id => @topic.id, 
:body => @body}, {:id => 'link', :target => "_blank"} %>

Any ideas?
-- 
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: Creating records with file upload in migration

2009-01-27 Thread Patrick Doyle
On Tue, Jan 27, 2009 at 2:26 PM, Dan Smith  wrote:

>
> Hi,
> I have a migration which creates several records along with the table.
> eg
> Forum.create :title => "General Discussion", :description => "General
> Chit-Chat"
>
> But I'd like to create a record which accepts an uploaded file, such as
> a jpeg.  Is it possible to automate this using the above technique?
>
> Thanks
>
How does your Forum model currently upload a file?  Do you use an after_save
callback to write the file into your file storage directory?  Could you
modify your callback to accept a filename from somewhere else in the
filesystem and have it simply copy that file to your file storage directory?

--wpd

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



[Rails] ActiveRecord: Least surprise? Really?

2009-01-27 Thread Steve H

OK I AM new to RoR, and I have more experience with Java and straight
SQL.  So maybe I'm just so used to thinking in a way that is
anticipating more than "least" surprise.  Anyway, here's what
surprised me:

If I have an object that belongs to another object, I would expect the
parent to have the FK to the child, not the other way around.

Why?  Because if I were to do it in memory (forget about persistence
for a minute), it would like kinda like this:

p = Parent.new
p.children << Child.new

Now in this example, p has an array of children (as in, it HAS MANY).
If I wanted to do a two-way relationship, I would do:

p = Parent.new
c = Child.new
p.children << c
c.parent = p

In this case, the parent has an array of children (literally a list of
many references to its children), and the child has a single reference
to a parent (assuming an xml-like hierarchy here, not a family-tree
type hierarchy).

Anyway, when I create a "has_one" association, I would expect this
object's table to literally have a FK column for the "child" object.
When I create a "belongs_to" association, I would expect the same
thing.

When I create a "has_many" association, I would expect a fact table
"parent_child" to be created (with id, parent_id, and child_id
columns), and if I wanted a two-way relationship, I would add
"belongs_to" to the Child.



What's my point?
Glad you asked.

If I wanted to create a class that maintains various user lists:
class UserLists < ActiveRecord::Base
  has_many :naughty, :class => "User"
  has_many :nice, :class => "User"
  has_many :absent, :class => "User"
end

I would expect some fact tables to be created: naughty_users (with
columns id, userlist_id, user_id), nice_users (with id, userlist_id,
user_id), and absent_users (again with id, userlist, and id).
-

Could someone set my thinking straight here?  Maybe I just need a
little explanation around best practices or something
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: [ActiveRecord] How to automatically bind, for example, :rows with Row or :user_id with User ?

2009-01-27 Thread Pierre L


Thank you !

On 26 jan, 13:55, Frederick Cheung  wrote:
> On 25 Jan 2009, at 23:08, Pierre L wrote:
>
>
>
> > Hello,
>
> > Imagine that I have the two following models :
> > class A < ActiveRecord::Base
> > belongs_to :b, :foreign => :fkey
> > end
>
> > class B < ActiveRecord::Base
> > end
>
> > Is it possible to retrieve both classes A and B and that column fkey
> > is pointing to table B ? In other words, if I give :a and :fkey, how
> > to obtain the class A and the fact that 'fkey' is a foreign key
> > pointing to table 'B' ?
>
> If you're looking to introspect what associations have been setup then  
> you'd want to look at A.reflections.
>
> Fred
>
>
>
>
>
> > I am almost sure that AR can do that, but this is not well-documented,
> > and source-code is a bit obsucated...
>
> > Thank you in advance,
> > Pierre L.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] request.env variables in an observer

2009-01-27 Thread Dowker

I have a scenario were I would like to inject the IP address and
UserAgent into an email when a database record is saved. I was
thinking of implementing this via an observer but I don't know how to
access the environment variables. Could anybody help or would this
break Rails best practices and I should implement this differently.

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] Creating records with file upload in migration

2009-01-27 Thread Dan Smith

Hi,
I have a migration which creates several records along with the table.
eg
Forum.create :title => "General Discussion", :description => "General
Chit-Chat"

But I'd like to create a record which accepts an uploaded file, such as
a jpeg.  Is it possible to automate this using the above technique?

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: Keeping separate lists of parent objects

2009-01-27 Thread Steve H

I think I've figured it out.  Sorry for posting what amounts to an
architectural question here, I'm guessing that's not really what this
board is for.

For anyone curious about what I decided to do:

I haven't totally decided yet.  I might trash the idea of a
"Verification" class, and instead opt for a Vote class:
Vote:
type
user

Then it would be a polymorphic association like this:
class Vote < ActiveRecord::Base
  belongs_to :voteable, :polymorphic => true
end

class Post < ActiveRecord::Base
  has_many :votes, :as => :voteable
end

class Product < ActiveRecord::Base
  has_many :votes, :as => :voteable
end



Otherwise if I stick with my verification class, I think I'll need to
do some sort of HMABT relationship, and I honestly don't see the
point.  So yeah.  I'll probably just do the Vote thing.

Cheers!


On Jan 27, 12:55 am, Steve H  wrote:
> OK here's the deal.  I have a Verification object that I want to use
> to allow users to verify data (Posts, Pics, Addresses, etc).  Each
> Post, Address, etc object will be related 1:1 to a Verification
> object.
>
> But I want to have the Verification keep 3 separate lists of users.  I
> have generated the following migration code, but i don't think it's
> going to work properly:
>   def self.up
>     create_table :verifications do |t|
>       t.references :voted_real
>       t.references :voted_fake
>       t.references :flagged
>
>       t.timestamps
>     end
>
> See I want voted_real to be a list of users who have voted "Real",
> similarly :voted_fake should be a list of users who have voted "Fake"
> and flagged to be a list of users who have "flagged" content (as
> offensive, inappropriate, etc).
>
> So you see, the standard options for ActiveRecord Associations will
> not suffice (as far as I can tell).
>
> Can someone help me out here?  I maybe just need a different design or
> maybe I can use polymorphic associations, but I'm not sure yet.  I
> think I can use polymorphic associations to associate the
> Verifications to the other objects, but not to accomplish what I want
> to do with the Verification to User relationship(s).
>
> I appreciate your help!!
>
> -Steve
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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 pass current value of form field in link_to?

2009-01-27 Thread Joe Peck

Greg wrote:
> Where is the value in the text field coming from?
It's coming from whatever the user is typing in, so not from the 
database :(


> If you want the text field to 
> dynamically update as the value of the text field is changed, then you
> should use Javascript, such as something along these lines:
> 
> 
>  Default text 

Thanks, that's almost what I'm looking for.  I'm having trouble passing 
the value of link to the "preview" action... instead, when I hit 
"preview" now, it shows value of the text field below the text field.

I guess I just need to set the value of a ruby variable equal to 
link.innerHTML somehow...
-- 
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] Extending AR to write audit columns

2009-01-27 Thread James Byrne

Rails 2.2.2
Ruby 1.8.5

I am attempting to extend AR with a generalized audit attribute setter.
I have written this code, which does not work for reasons unknown to me.
Perhaps someone here can explain why it does not.

# Put this in config/initializer as active_record_addins.rb
module ActiveRecord

  module HLLAuditStamps

def self.included(base)
  super
  # alias_method_chain  :create,:audit
  # is the same as:
  # alias_method:create_without_audit,  :create
  # alias_method:create,:create_with_audit

  base.alias_method_chain  :create,:audit
  base.alias_method_chain  :update,:audit

end

private

def create_with_audit
  write_audit_fields
  # Now we call our alias to the original method
  create_without_audit
end

def normal_time_now
  if base.class.default_timezone == :utc
return DateTime.now.utc
  else
return DateTime.now
  end
end

def update_with_audit
  write_audit_fields
  update_without_audit
end

def write_audit_fields
  write_attribute('accessed_at', normal_time_now) if \
  respond_to?('accessed_at')
  write_attribute('accessed_on', normal_time_now) if \
  respond_to?('accessed_on')
end

  end

end

What I intend is that whenever the AR create or update method is called
then the attributes specified in write_audit_fields are set to the value
provided by normal_time_now.  They are not and I cannot tell why.

Any suggestions as to what I am doing wrong?
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Multi table inheritance problem with has_one relationship

2009-01-27 Thread Rémi Gagnon

Here is my issue

class TransactionProduct < ActiveRecord::Base
  has_one :product, :class_name => 'Product'
end

class Product < ActiveRecord::Base
  set_inheritance_column :class_name
end

class ProductVT < Product
 def self.base_class
ProductVt
  end
end

So when I do

Product.find(:first) I got an instance of ProductVT with only the
columns of Product, which is ok.  Then when I do reload like this :

Product.find(:first).reload

I do have a complete instance of ProductVT.

But

When I do nagivate on Product from TransactionProduct and I do reload on
the instance of ProductVT it does not reload the ProductVT, it does it
on Product

TransactionProduct.find(:first).product.relaod  (reload the product
instance instead of ProductVT)

Even if I see in the console that is a ProductVT it reloads Product.  I
checked in development.log and in performs the query on Product.


Any idea.


Note : A temp fix is the to do a
Product.find(TransactionProduct.find(:first).product).reload, which is
ugly
-- 
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] Right way to do

2009-01-27 Thread James Bond

What is the right way to print localizations?

<%=t :User %> OR <%=t "User" %> OR <%=t ("User") %>

<%=t :User %> works fine, but <%=t :User.Username %> doesn't, but this
works:
<%=t ("User.Username") %>
-- 
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: Is there a "touch" method for associated records?

2009-01-27 Thread Duane Morin

Thanks, Denis.  The project in question is actually a periodic email 
pull for marketing purposes, which is why I'm taking pains to model a 
"one email per user" expectation, something that current project does 
not have. (I'll work them into an actual login/password protected 
profile later...)  The reason that the updated_at is important is the 
nature of the marketing message, which will be one of those "Since you 
visited the site 2 days ago" sorts of things.  If a user registered 
for the first time (and created a User object) 3 days ago, but then came 
back in today, registered again (and thus linked to but did not create a 
User object), I would not want to send that message to that person.
So I need some way to touch the User object at each registration.

I think the option to create a different dedicated field on User, like 
maybe last_registered_at, works best - it clearly defines the meaning of 
the field for the next developer who comes along.

D


Denis Haskin wrote:
> I can see why you'd want to do this, but I'd leave User.updated_at alone
> and track this 'dirtiness' in some other way.
> 
> There's no reason you can't do it, but as you say you'd have to
> accomplish it with an AR callback on Registration, not User.
> 
> The default way automatic timestamping is implemented in AR implies that
> the semantics of the updated_at timestamp are when the object *itself*
> was updated.  If you change this behavior, you run some risk of a future
> developer (or yourself in the future) not realizing that updated_at
> *also* means the user's registrations had changed.  (As you said: "but
> User isn't
> technically changing".)  You also then lose the ability to know when the
> User object itself was changed, as opposed to the list of registrations
> (but maybe you don't need to be able to make that differentiation).
> 
> If I were convinced I needed to do it this way, I would probably add a
> method User#registrations_changed and have the Registration callback
> call that, so that this behavior is explicit (and, as you desired,
> visible in the User class).  And would this be better on after_save, not
> before_save?
> 
> And what events in the association would update the user?  Adds,
> deletes, modifies?
> 
> My approach on this would also depend on why I needed to have the user's
> update date be updated like this; how are you going to use that fact,
> and could it be done by coming into the association via registrations?
> E.g. "show me the users whose registrations changed yesterday" could
> still, I think, be done fairly efficiently even without what you're
> proposing.
> 
> dwh

-- 
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: newbie question: types???

2009-01-27 Thread Steve H

Awesome!! Thanks that helps a lot.  One follow-up question, if I may:

>From what I've read, it seems that "references" are only to be used
for "belongs_to" associations?  Is it best practice to simply avoid
using "references" and just manually use (for example):

(Using script/generate)
customer_id:integer

(Or manually doing a migration file)
t.customer_id  :integer

???

I guess my question is: what is recommended best practice for using
"references"?

Thanks again for your help thortos!

-Steve

On Jan 27, 4:46 am, thortos  wrote:
> Hi Steve,
>
> > My first thought was "Nice!! So they demo string and text. What are
> > the differences between these two, and what other types are
> > available?"
>
> The types Active Record supports
> are :primary_key, :string, :text, :integer, :float, :decimal, :datetime, 
> :timestamp, :time, :date, :binary, :boolean.
>
> (Source:http://guides.rails.info/migrations.html)
>
> Also, on api.rubyonrails.org I found the following information pretty
> quickly:
>
> http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/Ta...
>
> Generally speaking, you usually find all you need in the Rails guides
> and the API documentation. Now I wish there was some usable way of
> finding answers to questions where you *don't* know which part of
> Rails is doing the magic. I'd love to have some documentation based on
> the *topic*, like this here:http://www.php.net/manual/en/funcref.php
>
> Newbies (like myself!) also tend to be confused at times when trying
> to find out whether our question is a Ruby or a Rails question.
> Thankfully the Rails community is pretty friendly. :-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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 pass current value of form field in link_to?

2009-01-27 Thread Greg

Where is the value in the text field coming from?  If it's coming from
your app (e.g. from the database or from a user passing parameters),
then you can do this on the Rails side of things, and it seems most
likely that you want to set an instance variable in the controller
(e.g. @text_field_value = [value]), which you can then use in both
your link_to and text_field.  If you want the text field to
dynamically update as the value of the text field is changed, then you
should use Javascript, such as something along these lines:


 Default text 

Best of luck,

Greg

On Jan 27, 12:54 pm, Joe Peck 
wrote:
> FWIW, I'm opening "preview" in another window.
>
> For right now, I plan on passing the current value of the text_field by
> setting params[:body] equal to it, but that doesn't seem to be the best
> idea.  Is there a better way to pass the current value to the "preview"
> action?
> --
> 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: Doing max of N tasks per given time

2009-01-27 Thread Greg

You should look into AR Mailer:

http://seattlerb.rubyforge.org/ar_mailer/

The basic idea is that rather than actually sending emails, your app
saves emails to the database.  AR Mailer then has an external script
which can be used to send these emails in batches.

Best of luck,

Greg

On Jan 27, 5:19 am, Ramon Tayag  wrote:
> Hey everyone,
>
> PROBLEM
> I need some help.  I have a Rails app on a VPS that connects to an
> external SMTP server that can only send up to 250 emails per hour.  If
> I try to send the 251st email, it will just ignore it.
>
> SENDMAIL?
> I almost bashed my head trying to setup sendmail so I can send my own
> emails, but not all emails were being sent.
>
> FANCY MOVES
> I basically want to send up to 250 emails immediately, and queue the
> 251st email til after the next hour since the max limit of 250 will be
> reset.  What can I use/install that does this for me?  If I can avoid
> installing postfix and sendmail or some other MTA program, it'll be
> way simpler for me.
>
> Thanks,
> Ramon Tayag
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to pass current value of form field in link_to?

2009-01-27 Thread Joe Peck

FWIW, I'm opening "preview" in another window.

For right now, I plan on passing the current value of the text_field by 
setting params[:body] equal to it, but that doesn't seem to be the best 
idea.  Is there a better way to pass the current value to the "preview" 
action?
-- 
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] Use URL only if aviable

2009-01-27 Thread Andi Geheim

hi

I have an RSS feed on my page and if the rss source is not aviable it
prints out an error.



<%= parseFeed("http://www.domain.de/phpBB3/rss.php";, 10) %>



How can I tell ruby only to use the rss feed if the rss source is
aviable?

something like unless? or so?



Greetings Chaos
-- 
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: Merging array with same key - HELP

2009-01-27 Thread Harold

Hi,

hash = {}
array1.uniq.each { |d| hash[d] = [] }
array1.each_with_index { |x,i| hash[x] << array2[i] }
hash.each_key { |key| hash[key] = hash[key].join('-') }
hash.inspect # => {"01/01/2009"=>"1stjan1-1stjan2-1stjan3",
"10/01/2009"=>"10thjan1-10thjan2"}

Enjoy,

-Harold
On Jan 27, 2:13 am, Shankar Ganesh 
wrote:
> Hi ,
>    I need to merge an array in ruby on rails.
>
>    array1 =
> ['01/01/2009','01/01/2009','10/01/2009','01/01/2009','10/01/2009']
>    array2 = ['1stjan1','1stjan2','10thjan1','1stjan3','10thjan2']
>
>    I need to have array like this
>
>    array3 =
> ['01/01/2009'=>'1stjan1-1stjan2-1stjan3','10/01/2009'=>'10thjan1-10thjan2']
>
>   Thanks in Advance.
> --
> 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: Merging array with same key - HELP

2009-01-27 Thread Harold

Hi,

hash = {}
array1.uniq.each { |d| hash[d] = [] }
array1.each_with_index { |x,i| hash[x] << array2[i] }
hash.each_key { |key| hash[key] = hash[key].join('-') }
hash.inspect # => {"01/01/2009"=>"1stjan1-1stjan2-1stjan3",
"10/01/2009"=>"10thjan1-10thjan2"}

Enjoy,

-Harold
On Jan 27, 2:13 am, Shankar Ganesh 
wrote:
> Hi ,
>    I need to merge an array in ruby on rails.
>
>    array1 =
> ['01/01/2009','01/01/2009','10/01/2009','01/01/2009','10/01/2009']
>    array2 = ['1stjan1','1stjan2','10thjan1','1stjan3','10thjan2']
>
>    I need to have array like this
>
>    array3 =
> ['01/01/2009'=>'1stjan1-1stjan2-1stjan3','10/01/2009'=>'10thjan1-10thjan2']
>
>   Thanks in Advance.
> --
> 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: Is there a "touch" method for associated records?

2009-01-27 Thread Denis Haskin
I can see why you'd want to do this, but I'd leave User.updated_at alone 
and track this 'dirtiness' in some other way.

There's no reason you can't do it, but as you say you'd have to 
accomplish it with an AR callback on Registration, not User.

The default way automatic timestamping is implemented in AR implies that 
the semantics of the updated_at timestamp are when the object *itself* 
was updated.  If you change this behavior, you run some risk of a future 
developer (or yourself in the future) not realizing that updated_at 
*also* means the user's registrations had changed.  (As you said: "but 
User isn't
technically changing".)  You also then lose the ability to know when the 
User object itself was changed, as opposed to the list of registrations 
(but maybe you don't need to be able to make that differentiation).

If I were convinced I needed to do it this way, I would probably add a 
method User#registrations_changed and have the Registration callback 
call that, so that this behavior is explicit (and, as you desired, 
visible in the User class).  And would this be better on after_save, not 
before_save?

And what events in the association would update the user?  Adds, 
deletes, modifies?

My approach on this would also depend on why I needed to have the user's 
update date be updated like this; how are you going to use that fact, 
and could it be done by coming into the association via registrations?  
E.g. "show me the users whose registrations changed yesterday" could 
still, I think, be done fairly efficiently even without what you're 
proposing.

dwh


Duane Morin wrote:
> I'm sure I can whip something up to do this, but I'm wondering an
> elegant solution already exists.  I will have any number of Registration
> objects coming in through web form, but I wish there to be only one User
> object per unique email address.  So far this works fine.  So
> Registration belongs_to User, User has_many Registrations.  (This, by
> the way, is because the site does not have a persistent profile/logged
> in session and thus the same person could fill out the registration form
> multiple times.)
>
> What I'd like is if a person comes in a second time, creates a
> Registration object using an email address that already has an
> associated User, then update the User.updated_at field.  In other words,
> the clean/dirty status of User is based on the most recent Registration
> object that was added.
>
> Does such a feature already exist in the association?  I figure I could
> get around it altogether by defining User.updated_at as the max of
> registrations.updated_at, but that's pretty inefficient.  My other
> option is just to put in some sort of before_save filter on
> Registration.  But it seems better placed on User - but User isn't
> technically changing during this operation, right?  So I'm not sure
> where I'd hook in.
>   

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: Migration Broken?? *FIXED*

2009-01-27 Thread Juan José Vidal

You could use this script to rename all your migrations with the new 
format.
I've used this chunk of code in a project (undeployed yet) to normalize 
the migrations names (01_, 02_ ... format and UTC format)
Maybe could be useful for you.

#!/usr/bin/env ruby

require 'find'
require 'fileutils'
require 'optparse'


# Create option parser.
options = {}
ARGV.options do |opts|
  opts.banner << " "
  opts.on("-v", "--[no-]verbose", "run verbosely") do |v|
options[:verbose] = v
  end

  opts.on("-l", "--[no-]local", "make local changes") do |v|
options[:local] = v
  end

  opts.on("-s", "--[no-]subversion", "remane files on subversion") do |v|
options[:subversion] = v
  end

  opts.on("-g", "--[no-]git", "remane files on git") do |v|
options[:git] = v
  end

end.parse!

path = ARGV[0] or (STDERR.puts ARGV.options; exit 2)

printf "\033[1m\033[33mRename Ruby On Rails Migrations UTC (1 sec) 
\033[0m\n"
printf "\033[1m\033[33mbinoid 09/2008- we make webapps\033[0m\n"
sleep(2)

Dir.entries(path).sort.each do |old_name|
  if !File.directory?("#{path}/#{old_name}")
new_name = old_name.gsub(/\d+/, Time.now.strftime("%Y%m%d%H%M%S"))

puts ">> rename #{path + old_name} to #{path + new_name}\n" if 
options[:verbose]
File.rename(path + old_name, path + new_name) if options[:local]
system( "svn mv #{path + old_name} #{path + new_name}" ) if 
options[:subversion]
system( "git-rename #{path + old_name} #{path + new_name}" ) if 
options[:git]
sleep(1)
  end
end


(Sorry, I don't remember from where I copied this code)


Michael Satterwhite escribió:
> Frederick Cheung wrote:
>
>   
>> Do you also have a schema migrations table ? if so I'd try dropping
>> it. This is the replacement for the schema_info table, and should be
>> automatically created so that migrations are assumed to have run up to
>> the right point but might have got screwed up.
>> 
>
> Thanks much. That solved the problem.
>
>   


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



[Rails] Re: Migration Broken?? *FIXED*

2009-01-27 Thread Michael Satterwhite

Frederick Cheung wrote:

> Do you also have a schema migrations table ? if so I'd try dropping
> it. This is the replacement for the schema_info table, and should be
> automatically created so that migrations are assumed to have run up to
> the right point but might have got screwed up.

Thanks much. That solved the 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] How to pass current value of form field in link_to?

2009-01-27 Thread Joe Peck

Greetings to you,

I'm trying to write a "preview" link, and need to pass along the current
value of a text_field to this link.

I figure there is some simple Javascript way to do this, but so far
haven't figured it out.

Does anyone know how to get and pass the current value of a text_field
to link_to?
-- 
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] Is there a "touch" method for associated records?

2009-01-27 Thread Duane Morin

I'm sure I can whip something up to do this, but I'm wondering an
elegant solution already exists.  I will have any number of Registration
objects coming in through web form, but I wish there to be only one User
object per unique email address.  So far this works fine.  So
Registration belongs_to User, User has_many Registrations.  (This, by
the way, is because the site does not have a persistent profile/logged
in session and thus the same person could fill out the registration form
multiple times.)

What I'd like is if a person comes in a second time, creates a
Registration object using an email address that already has an
associated User, then update the User.updated_at field.  In other words,
the clean/dirty status of User is based on the most recent Registration
object that was added.

Does such a feature already exist in the association?  I figure I could
get around it altogether by defining User.updated_at as the max of
registrations.updated_at, but that's pretty inefficient.  My other
option is just to put in some sort of before_save filter on
Registration.  But it seems better placed on User - but User isn't
technically changing during this operation, right?  So I'm not sure
where I'd hook in.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: manipulating "params[:some]" with ActiveRecod::Find on ":select" method

2009-01-27 Thread Frederick Cheung


On 27 Jan 2009, at 16:10, flaubert wrote:
>
> So, the SQL returns an error, the fields are going together w/o spaces
> or comma!
>
> How to convert the params[:some] into a formatted string to make sql
> works:?:
>
That entirely depends on what is in params[:some] (beware sql  
injection too - can't remember to what extent AR protects you there)

Fred

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



[Rails] Re: Migration Broken??

2009-01-27 Thread Frederick Cheung


On 27 Jan 2009, at 16:11, Michael Satterwhite wrote:

>
> I've created a migration to create a new table. I'm noting that the
> format of the migration name created by the generator has changed. Up
> until now, the migration names were of the form "00n_" ... now  
> the
> form is _.
It's a UTC timestamp
>
>
> The problem that I'm having is that rake db:migrate is trying to rerun
> all my migrations from "001" forward. the schema tables in the  
> database
> show the schema to be at 19. I would have expected the new migration  
> to
> be 020_, but the name format has changed as shown above.
>
Do you also have a schema migrations table ? if so I'd try dropping  
it. This is the replacement for the schema_info table, and should be  
automatically created so that migrations are assumed to have run up to  
the right point but might have got screwed up.

Fred
> Obviously, something has changed in this area. I've tried googling,  
> but
> I haven't found the right search terms. How do I get migrations to run
> again. I'd be happy to reset everything to the current state of the
> database, then move forward with the new migration. I'd be happy  
> just to
> get it working again.
>
> Can anyone offer any 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: how to create a permanent record in table

2009-01-27 Thread Robert Walker

Robert Walker wrote:
> I'd say use the the before_destroy callback to validate the deletion:
> 
> def before_destroy
>   !project_name.eql?("No project")
> end

On second thought this might be a better approach:

class Project < ActiveRecord::Base
  before_destroy :protect_no_project

  private
  def protect_no_project
!name.eql?("No project")
  end
end

It sounds like overriding the callback directly may not be 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
-~--~~~~--~~--~--~---



[Rails] Migration Broken??

2009-01-27 Thread Michael Satterwhite

I've created a migration to create a new table. I'm noting that the
format of the migration name created by the generator has changed. Up
until now, the migration names were of the form "00n_" ... now the
form is _.

The problem that I'm having is that rake db:migrate is trying to rerun
all my migrations from "001" forward. the schema tables in the database
show the schema to be at 19. I would have expected the new migration to
be 020_, but the name format has changed as shown above.

Obviously, something has changed in this area. I've tried googling, but
I haven't found the right search terms. How do I get migrations to run
again. I'd be happy to reset everything to the current state of the
database, then move forward with the new migration. I'd be happy just to
get it working again.

Can anyone offer any 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] manipulating "params[:some]" with ActiveRecod::Find on ":select" method

2009-01-27 Thread flaubert

Hello all,


I trying to pass the params from a form to the :select (field list) in
my controller

like this => Processo.find  :all,:conditions => {
  :tipo_acao_id =>
params[:tipo_acao_id],
  :fase_id =>
(params[:fase_id]),
  :resultado_id =>
(params[:resultado_id]),
  :situacao_id =>
(params[:situacao_id]),
  :justica_id =>
(params[:justica_id])
}, :select =>
params[:some]



So, the SQL returns an error, the fields are going together w/o spaces
or comma!

How to convert the params[:some] into a formatted string to make sql
works:?:

tnks a lot!!!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: ruby script/server ERROR

2009-01-27 Thread Basma Basma

many thanks to you Fred :)
it's working now.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: how to create a permanent record in table

2009-01-27 Thread Robert Walker

Andrew Timberlake wrote:
> Set the model readonly
> 
> class MyModel < ActiveRecord::Base
>   def initialize(*args)
> super(*args)
> readonly!
>   end
> end
Wouldn't this make all records of the table read only? I don't think 
that's what the OP wanted.

I'd say use the the before_destroy callback to validate the deletion:

def before_destroy
  !project_name.eql?("No project")
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: format.atom w Rails 2.2

2009-01-27 Thread Erwin

mistaken   shoudl write  changes.rxml  and not xml.builder !!!
dawned copy/paste !!

On 27 jan, 16:10, Erwin  wrote:
> in Rails 2.1, this works.. but I am stuck w Rails 2.2
>
> class PostsController < ApplicationController
>   def show
>      ..
>     respond_to do |format|
>       format.html
>       format.atom { render :action => 'changes', :layout =>
> false, :content_type => 'application/atom+xml' }
>     end
>   end
>
>   def changes
>      
>     respond_to do |format|
>       format.xml { render :layout => false, :content_type =>
> 'application/atom+xml' }
>     end
>   end
> ..
> end
>
> I have a view,  changes.xml.builder, building the xml code, but I got
> a missing template as an error, when 
> executinghttp://localhost:3000/posts/show/5
>
> ActionView::MissingTemplate (Missing template posts/changes.erb in
> view path .../Projects/franchising/app/views:):
> If I set a changes.erb, the xml code is sent...
>
> how should I write that w Rails 2.2 ?
>
> thanks a lot for your help
>
> erwin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: ruby script/server ERROR

2009-01-27 Thread Frederick Cheung


On 27 Jan 2009, at 15:10, Basma Basma wrote:

>
> Frederick Cheung wrote:
>> On 27 Jan 2009, at 14:48, Basma Basma wrote:
>>
>>>
>>> thanks Fred for replying.
>>> but what kind of errors?
>>> I wrote in database.yml
>>>
>> According to the error message there's a line with timeout: 5000 on  
>> it
>> Also indentation in yaml is significant.
>>
>> Fred
>
>
> yes there was a line with timeout: 5000
> then I remove it , to see if the error from it or not!
> and still same error!
>
>
> but what do you mean about "Also indentation in yaml is significant"?
> should be without indentation?

That means that what you pasted:

development:
adapter: mysql
database: web
host: localhost
username: root
password:

is very different from

development:
   adapter: mysql
   database: web
   host: localhost
   username: root
   password:

Also have all three environments set to use the same database is a  
very bad thing (unless you want all of them to get wiped everytime you  
run the unit tests).

Fred
>
>
> 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: Merging array with same key - HELP

2009-01-27 Thread anton effendi
send to me the file.. I will repair...

I think use:
 array3 = {}
  array1.each_with_index do |x, i|
  array3[x] = array2[i]
  end

On Tue, Jan 27, 2009 at 8:50 PM, Shankar Ganesh <
rails-mailing-l...@andreas-s.net> wrote:

>
>
> <%  array1
> =['01/01/2009','01/01/2009','10/01/2009','01/01/2009','10/01/2009'] %>
> <%array2 = ['1stjan1','1stjan2','10thjan1','1stjan3','10thjan2']%>
> <%array3 = {} %>
> <%array2.each_with_index do |x, i|%>
>  <%array3[x] = array1[i]%>
> <%end%>
> 
> <%=array3.inspect %>
>
> I'm getting o/p like this
>
>
> {"1stjan1"=>"01/01/2009", "10thjan1"=>"10/01/2009",
> "1stjan2"=>"01/01/2009", "10thjan2"=>"10/01/2009",
> "1stjan3"=>"01/01/2009"}
>
>
>
>
> anton effendi wrote:
> > make sure.
> > array1 --> date
> > array2 --> the value...
> >
> > or
> > array3 = {}
> > array1.each_with_index do |x, i|
> >  array3[x] = array2[i]
> > end
> >
> > change to
> >
> > array3 = {}
> > array2.each_with_index do |x, i|
> >  array3[x] = array1[i]
> > end
> >
> > please try again
> >
> > On Tue, Jan 27, 2009 at 3:56 PM, Shankar Ganesh <
> > rails-mailing-l...@andreas-s.net> wrote:
> >
> >> end
> >>
> ['01/01/2009'=>'1stjan1-stjan2-1stjan3','10/01/2009'=>'10thjan1-10thjan2']
> >> > thank you..
> >> >>   array3 =
> >> >
> >> > --
> >> > Wu You Duan
> >>
> >> --
> >> Posted via http://www.ruby-forum.com/.
> >>
> >> >
> >>
> >
> >
> > --
> > Wu You Duan
>
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>


-- 
Wu You Duan

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: ruby script/server ERROR

2009-01-27 Thread Basma Basma

Frederick Cheung wrote:
> On 27 Jan 2009, at 14:48, Basma Basma wrote:
> 
>>
>> thanks Fred for replying.
>> but what kind of errors?
>> I wrote in database.yml
>>
> According to the error message there's a line with timeout: 5000 on it
> Also indentation in yaml is significant.
> 
> Fred


yes there was a line with timeout: 5000
then I remove it , to see if the error from it or not!
and still same error!


but what do you mean about "Also indentation in yaml is significant"?
should be without indentation?

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] format.atom w Rails 2.2

2009-01-27 Thread Erwin

in Rails 2.1, this works.. but I am stuck w Rails 2.2

class PostsController < ApplicationController
  def show
 ..
respond_to do |format|
  format.html
  format.atom { render :action => 'changes', :layout =>
false, :content_type => 'application/atom+xml' }
end
  end

  def changes
 
respond_to do |format|
  format.xml { render :layout => false, :content_type =>
'application/atom+xml' }
end
  end
..
end


I have a view,  changes.xml.builder, building the xml code, but I got
a missing template as an error, when executing
http://localhost:3000/posts/show/5

ActionView::MissingTemplate (Missing template posts/changes.erb in
view path .../Projects/franchising/app/views:):
If I set a changes.erb, the xml code is sent...

how should I write that w Rails 2.2 ?

thanks a lot for your help

erwin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: logged_in?

2009-01-27 Thread Freddy Andersen

<% if logged_in? %>
I'm logged in
<% end %>

This is in a view...

On Jan 27, 5:50 am, Ralph Herve 
wrote:
> how to use this method
> --
> 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: ruby script/server ERROR

2009-01-27 Thread Frederick Cheung


On 27 Jan 2009, at 14:48, Basma Basma wrote:

>
> Frederick Cheung wrote:
>> On 27 Jan 2009, at 12:25, Basma Basma wrote:
>>
>>> I close it!
>>>
>>>
>> Sounds like a syntax error in database.yml.
>>
>> Fred
>
> thanks Fred for replying.
> but what kind of errors?
> I wrote in database.yml
>
According to the error message there's a line with timeout: 5000 on it
Also indentation in yaml is significant.

Fred
>
> development:
> adapter: mysql
> database: web
> host: localhost
> username: root
> password:
>
> test:
> adapter: mysql
> database: web
> host: localhost
> username: root
> password:
>
> production:
> adapter: mysql
> database: web
> host: localhost
> username: root
> password:
>
>
> --  
> 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   >