[Rails] Re: Help with a regular expressions and gsub

2009-04-20 Thread Andrew Timberlake

On Sun, Apr 19, 2009 at 10:56 PM, John Smith
rails-mailing-l...@andreas-s.net wrote:

 Andrew Timberlake wrote:
 On Sat, Apr 18, 2009 at 9:35 AM, John Smith
 rails-mailing-l...@andreas-s.net wrote:

 I'll appreciate any help.

 Use word break matches in your regular expression as follows:

 string.gsub(/\bcar\b/, 'bike')

 Andrew Timberlake
 http://ramblingsonrails.com
 http://www.linkedin.com/in/andrewtimberlake

 I have never let my schooling interfere with my education - Mark Twain

 Thanks. What if I have...?

 Lorem ipum car. Locar ipsum,pcar lorem ipusum/p.Lorem car ipsum.
 Lorem a href='#'car/a ipsum.

 And now I want to obtain the same but I do not want to obtain a
 href='#'bike/a,


This will start to get tricky as it becomes important to know what the
rules really are.
Are you wanting to avoid car surrounded by an anchor tag, or car
surrounded by any tag.
pcar lorem ipusum/p will pose a problem as it's half surrounded by a tag.

so to satisfy your test case, the following works by making sure that
car is not followed by a '' which will work on both cases mentioned
above.

string.gsub(/\bcar\b(?=[^])/, 'bike')
This checks that car is surrounded by a word-break but is not followed by a ''

If, in Ruby 1.9, I do the following:
string.gsub(/(?!)\bcar\b(?=[^])/, 'bike')
I am now checking that car is surrounded by a word-break and is not
preceded by a '' and not followed by a '' however this pattern will
not replace pcar lorem with pbike lorem

Andrew Timberlake
http://ramblingsonrails.com
http://www.linkedin.com/in/andrewtimberlake

I have never let my schooling interfere with my education - Mark Twain

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



[Rails] Re: Facebooker cannot post event

2009-04-20 Thread Akhilesh Sharma

hi dude,
i am also facing the same problem of creating event using facebooker and 
doesn't get anything useful. Are you able to solve this issue. if yes 
then please help me out by providing the way you took to solve that.

Regards,
Akhilesh sharma
akhileshaksha...@gmail.com

Artūras Šlajus wrote:
 I'm trying to do it with this code:
 
   def create_event(options={})
 options.assert_valid_keys(:uid, :event)
 session = create_session
 event = options[:event]
 # Note: The start_time and end_time are the times that were input by
 the event creator,
 # converted to UTC after assuming that they were in Pacific time
 (Daylight Savings or
 # Standard, depending on the date of the event), then converted into
 Unix epoch time.
 # Basically this means for some reason facebook does not want to get
 epoch timestamps
 # here, but rather something like epoch timestamp minus 7 or 8
 hours, depeding on the
 # date. have fun!
 #
 # http://wiki.developers.facebook.com/index.php/Events.create
 start_time = (event.start - 10.hours).utc.to_i
 end_time = event.end ? (event.end - 10.hours).utc.to_i : start_time
 
 session.post(events.create, {
   'event_info' = {
 'name' = event.title,
 'category' = event.facebook_category.to_s,
 'subcategory' = event.facebook_subcategory.to_s,
 'host' = event.organizers.blank? ? event.place.title :
 event.organizers_as_string,
 'location' = event.place.title,
 'street' = event.place.address,
 'city' = event.city.to_s,
 'description' = event.description || '',
 'privacy_type' = 'SECRET',
 'start_time' = start_time,
 'end_time' = end_time
   }.to_json
 })
   end
 
 However..
 
 c:/ruby/lib/ruby/gems/1.8/gems/mmangino-facebooker-1.0.12/lib/facebooker/parser.
 rb:487:in `process': event_info parameter: array expected.
 (Facebooker::Session:
 :MissingOrInvalidParameter)
 
 Any ideas on what's happening? :|

-- 
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] [noob question] View error, Resource route

2009-04-20 Thread Paul A.

Hello everyone,

I have a little problem, since I have change my route from resources to
resource. My files look like:

# config/routes.rb
ActionController::Routing::Routes.draw do |map|
  map.resource :system
end

# app/controllers/systems_controller.rb
class SystemsController  ApplicationController
  def new
@system = System.new
  end
end

# app/views/systems/new.html.erb
% form_for @system do |f| %
%= f.error_messages %

And here is my error message:

NoMethodError in Systems#new

Showing app/views/systems/new.html.erb where line #1 raised:

undefined method `systems_path' for #ActionView::Base:0x3459fe0
Extracted source (around line #1):

1: % form_for @system do |f| %
2: %= f.error_messages %
3:
4: dl
RAILS_ROOT: /Users/pulu/Sites/test

Do you think I get an error in new.html.erb?

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: Help with a regular expressions and gsub

2009-04-20 Thread John Smith

Thanks. When I use . what I need is to obtain pbike/p and a 
href='#'car/a.

-- 
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] Web based GUI components in Rail Project

2009-04-20 Thread gunvant

Hi Friends,

I want to use extra ordinary web based GUI component in rail project.
could you please tell me from where i can get such kind of web based
component like (table, datetime picker, msg box, input fields, etc...)

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] need help with controller/show.html.erb

2009-04-20 Thread Michael R

Hello,

I am attempting to display data in the requseraccount form, from the
divisions table.

For example: I have a division_id field in requseraccount that works
great. No issues getting this populated from my create form. The
problem is that I don't want to display the id when showing the form.
I want to display the division_name, which is in the division table.

Here is a copy of my code
requseraccounts_controller.rb and schema.rb: http://dpaste.com/35716/
requseraccoutns: show.html.erb:  http://dpaste.com/35717/
SQL Query: http://dpaste.com/35725/

I get the following error when I try the above code:

 ActiveRecord::RecordNotFound in RequseraccountsController#show

   Couldn't find Division with ID=8

Which makes sense, since it is trying to do a query WHERE
division_id=8. I need the query to use requseaccount.divisions_id
(which is 2) and not requseraccount.id (which is 8).

Any advice would be much appreciated.

Michael

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



[Rails] Affiliate plugin

2009-04-20 Thread Joshua Needham

Hello all,

I've been looking around everywhere for a valid plugin that will allow  
for creation of an affiliate account along with a specific link for  
the signup.

Additionally it would need the ability to track sales with the link  
and possibly a cookie for returning customers.

I've looked at the affiliate project that's available via github but  
it's not complete. I'm looking for a working plugin for my indicated  
purposes.

Thanks,
Joshua

Sent from my iPhone

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



[Rails] Re: Help with a regular expressions and gsub

2009-04-20 Thread Andrew Timberlake

On Mon, Apr 20, 2009 at 9:15 AM, John Smith
rails-mailing-l...@andreas-s.net wrote:

 Thanks. When I use . what I need is to obtain pbike/p and a
 href='#'car/a.


I'm starting to think that regular expressions are not the best way to
solve this.
You should probably use an HTML parser and then do regular expression
substitutions based on where in the DOM you are

Andrew Timberlake
http://ramblingsonrails.com
http://www.linkedin.com/in/andrewtimberlake

I have never let my schooling interfere with my education - Mark Twain

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



[Rails] Re: View error, Resource route

2009-04-20 Thread Gavin

try...
% form_tag system_path do %


using @system is a shortcut way of writing systems_path but it looks
for the plural path - you've set yours to a singular resource path

run rake routes to see your available paths in the terminal window.

Hope that helps

On Apr 20, 8:07 am, Paul A. rails-mailing-l...@andreas-s.net
wrote:
 Hello everyone,

 I have a little problem, since I have change my route from resources to
 resource. My files look like:

 # config/routes.rb
 ActionController::Routing::Routes.draw do |map|
   map.resource :system
 end

 # app/controllers/systems_controller.rb
 class SystemsController  ApplicationController
   def new
     @system = System.new
   end
 end

 # app/views/systems/new.html.erb
 % form_for @system do |f| %
 %= f.error_messages %

 And here is my error message:

 NoMethodError in Systems#new

 Showing app/views/systems/new.html.erb where line #1 raised:

 undefined method `systems_path' for #ActionView::Base:0x3459fe0
 Extracted source (around line #1):

 1: % form_for @system do |f| %
 2: %= f.error_messages %
 3:
 4: dl
 RAILS_ROOT: /Users/pulu/Sites/test

 Do you think I get an error in new.html.erb?

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



[Rails] Re: Testing and SQL views.

2009-04-20 Thread Michael Schuerig

On Monday 20 April 2009, Tim Uckun wrote:
  http://github.com/aeden/rails_sql_views/tree/master
 
  and my heavily hacked version
 
  http://github.com/mschuerig/rails_sql_views/tree/master
 
  My version works with Rails 2.3.2, loads only the adapters that are
  really needed, and adds ActiveRecord::View as an abstract
  superclass for views that are mostly based on another model.
  AR::View can clone association definitions from the model to the
  view, although I haven't implemented all kinds yet. The existing
  functionality works on PostgreSQL, regarding the others, I'm not
  sure right now.

 Michael I have downloaded your code and it does work a lot better.

 Although it fixed the original problem now it presents another
 problem Either the rails framework or the postgres adapter attempts
 to change the triggers in the table using ALTER TABLE which causes
 an error.

The only code I can see that affects triggers is in the original 
PostgreSQLAdapter#disable_referential_integrity method. It disables 
triggers during a block and re-enables them afterwards. As far as I 
remember, this is used to load fixtures while temporarily suspending the 
triggers. As fixture files are loaded one by one without regard for 
foreign keys, the temporarily violated constraints would cause an 
exception. I don't think the behavior you're seeing is related to views

 Do I have to make my models which derive from view inherit from
 AR:View?

No, that's just for convenience if you like to re-use associations from 
other models.

Michael

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


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



[Rails] Re: Help with a regular expressions and gsub

2009-04-20 Thread Andrew Timberlake

On Mon, Apr 20, 2009 at 10:38 AM, John Smith
rails-mailing-l...@andreas-s.net wrote:

 Thanks again for yyour help.
 Anyway, can you explain the meaning of (?=[^]). I know that [^] means
 no math '', but why should I use the '()' and '?='  ?

(?=pattern) is a look-ahead match that doesn't consume the characters matched
In string cartoon
/car(?=[^])/ will only match car and /car[^]/ will match cart
/car(?=[^])/ can actually be rewritten as /car(?!)/ where ?! is a
negative look ahead

(?pattern) is a look-behind match that doesn't consume the
characters matched (only Ruby 1.9)

Andrew Timberlake
http://ramblingsonrails.com
http://www.linkedin.com/in/andrewtimberlake

I have never let my schooling interfere with my education - Mark Twain

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



[Rails] Re: OT : SQLite or another database engine with a small application?

2009-04-20 Thread Fidel Viegas

On Sat, Apr 18, 2009 at 2:00 PM, César cesare.d...@gmail.com wrote:

 Many thanks Fidel. My apologizes to the list for re discuss something.

 Well, in my opinion if I have to select another database engine I will
 work with Postgres because I see this engine more powerful, more solid
 than MySql. It is just my opinion, MySql is good but I prefer
 Postgres.

Certainly!

I only suggested MySQL because of the requirements you specified.

Fidel.

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



[Rails] Re: View error, Resource route

2009-04-20 Thread Paul A.

Gavin Morrice wrote:
 try...
 % form_tag system_path do %

Thanks, Gavin. When I do this, I get an error at the line 2 about:
%= f.error_messages %

To solve it, I had just rewrite this line with:
%= error_messages %

But an other error message is occuring, saying that error_messages is 
not defined (if I remember well).
-- 
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: test:integration Expected response to be a :redirect, but was 404

2009-04-20 Thread elle

Changing add_product method to this passes without failure. I've
noticed before that I don't use urls with /show anymore -- therefore
eliminated it from the method. What I wanted to ask is: is this code
good enough? or am I missing something important?
TIA

def add_product(parameters)
  category = Category.find(:all).first

  get 'products/new'
  assert_response :success
  assert_template products/new.html.erb
  assert_tag :tag = 'option', :attributes = { :value =
category.id }

  post 'products/create', parameters
  assert_response :redirect
  follow_redirect!
  assert_response :success
  assert_template products/show.html.erb
  return Product.find_by_title(parameters[:product][:title])
end
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: xxx.valid? still true after xxx.errors.add(...)?

2009-04-20 Thread Joshua Muheim

Well, it seems that obj.valid? and obj.save remove all manually added 
errors?!

  @comment.errors.add_to_base(Captcha wurde nicht korrekt 
eingegeben)
  raise valid? #...@comment.valid?} - errors: 
#...@comment.errors.inspect}

results in valid? false - errors: #ActiveRecord::Errors:0x23d028c 
@base=#Comment id: nil, commentable_id: 38313, user_id: 1, subject: , 
body: , created_at: nil, updated_at: nil, commentable_type: 
Article, @errors={body=[can't be blank], subject=[can't be 
blank]}

and

  raise errors: #...@comment.errors.inspect}

results in errors: #ActiveRecord::Errors:0x1878538 @base=#Comment id: 
nil, commentable_id: 38313, user_id: 1, subject: , body: , 
created_at: nil, updated_at: nil, commentable_type: Article, 
@errors={base=[Captcha wurde nicht korrekt eingegeben]}

Why the heck does ActiveRecord remove my custom errors when calling 
.valid???

Thanks a lot for help
Josh
-- 
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] xxx.valid? still true after xxx.errors.add(...)?

2009-04-20 Thread Joshua Muheim

Hi all

I have the following code in my controller:

if @comment.valid?
  captcha_url =
http://captchator.com/captcha/check_answer/#{captcha_code}/#...@comment.captcha};
  result = open(captcha_url)
  unless result.read == 1
@comment.errors.add(:captcha, Captcha wurde nicht korrekt
eingegeben)
raise #...@comment.valid?}
  end
end

Although I'm adding an error to :captcha, when I raise @comment.valid?
on the next line this still gives me true! Why is that? I just added an
error to @comment, didn't I?!

Maybe it's because I'm only using an attr_accessor for captcha?

class Comment  ActiveRecord::Base
  validates_presence_of :captcha
  attr_accessor :captcha
end

Thanks
Josh
-- 
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] Using collection on has_many with :conditions.

2009-04-20 Thread Jarl Friis

Hi.

I have a has_many relation with a hashed condition, taking from the RI
doc:

:conditions
   Specify the conditions that the associated objects must
   meet in order to be included as a WHERE SQL fragment, such
   as price  5 AND name LIKE 'B%'. Record creations from the
   association are scoped if a hash is used. has_many :posts,
   :conditions = {:published = true} will create published
   posts with @blog.posts.create or @blog.posts.build.

I wonder why the behaviour of @blog.posts is not also modified when
using hashed conditions. The thing is when I have :conditions =
{:published = true} 

and issue @blog.posts.create(:published = false) will result in a new
(published) post, i.e. it will override the :published attributes,
the same holds for @blog.posts.build(:published = false), but when I
do a @blog.posts  Post.new(:published = false), it will not be
overruled by my condition, it will not even fail my condition. It will
simply end up in the database outside the scope of the condition.

Is this a design decision (of the has_many :condition attribute)? or
is this actually a bug/feature request?

Jarl


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



[Rails] Re: View error, Resource route

2009-04-20 Thread Gavin

Sorry - should have explained:

If you use the form_tag method then you can't pass a variable like |f|

you'd have to replace things like
f.text_field :your_field

with

text_field :system, :your_field

and use the error_messages_for method instead:
http://api.rubyonrails.org/classes/ActionView/Helpers/ActiveRecordHelper.html#M001662

I think you can use form_for as you did before but write it like:

% form_for :system, :url = {:action = :create} do |f| %

This would be the easiest option but I'm not 100% sure if that works
with a singular resource.

Would be curious to find out if it does?


On Apr 20, 10:14 am, Paul A. rails-mailing-l...@andreas-s.net
wrote:
 Gavin Morrice wrote:
  try...
  % form_tag system_path do %

 Thanks, Gavin. When I do this, I get an error at the line 2 about:
 %= f.error_messages %

 To solve it, I had just rewrite this line with:
 %= error_messages %

 But an other error message is occuring, saying that error_messages is
 not defined (if I remember well).
 --
 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: xxx.valid? still true after xxx.errors.add(...)?

2009-04-20 Thread Frederick Cheung



On Apr 20, 10:26 am, Joshua Muheim rails-mailing-l...@andreas-s.net
wrote:
 Well, it seems that obj.valid? and obj.save remove all manually added
 errors?!

       @comment.errors.add_to_base(Captcha wurde nicht korrekt
 eingegeben)
       raise valid? #...@comment.valid?} - errors:
 #...@comment.errors.inspect}

 results in valid? false - errors: #ActiveRecord::Errors:0x23d028c
 @base=#Comment id: nil, commentable_id: 38313, user_id: 1, subject: ,
 body: , created_at: nil, updated_at: nil, commentable_type:
 Article, @errors={body=[can't be blank], subject=[can't be
 blank]}

 and

       raise errors: #...@comment.errors.inspect}

 results in errors: #ActiveRecord::Errors:0x1878538 @base=#Comment id:
 nil, commentable_id: 38313, user_id: 1, subject: , body: ,
 created_at: nil, updated_at: nil, commentable_type: Article,
 @errors={base=[Captcha wurde nicht korrekt eingegeben]}

 Why the heck does ActiveRecord remove my custom errors when calling
 .valid???

Calling valid? recomputes the errors (there's no difference at the end
of the day between an error you added yourself and one from a 'normal'
validations. If you want to add errors yourself you should be doing so
from a validation

Fred

 Thanks a lot for help
 Josh
 --
 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] Referencing associated records in a named scope

2009-04-20 Thread Max Williams

Hi all

I have a situation like this:

  class Country
has_many :policy_indicator_ratings
has_many :policy_indicators, :through = :policy_indicator_ratings

  class PolicyIndicatorRating
belongs_to :country
belongs_to :policy_indicator

  class PolicyIndicator
has_many :policy_indicator_ratings
named_scope :water, :conditions = [sector = ?, 'water']
named_scope :sanitation, :conditions = [sector = ?,'sanitation']

Now, i want to say something like

  @country.policy_indicators.water.each do |indicator|
#do something with this country's rating for this indicator
  end

It feels like i'm now forced to do something like this inside the loop:

  rating =
PolicyIndicatorRating.find_by_country_id_and_policy_indicator_id(@country.id,
indicator.id)

This seems clumsy - i've gone through the join model to get the
indicator, and now i have to manually pull the join record out again.

Is there a way to set up the named scope on the join model, something
like this?

  #this won't work but gets the idea across
  named_scope :water, :conditions = (self.policy_indicator.sector ==
water)

??

Or, is there a nicer way to organise my schema to seperate out water
indicators from sanitation indicators?

Grateful for any advice.
thanks
max
-- 
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: need help with controller/show.html.erb

2009-04-20 Thread Paco Guzman

Hi Michael

You have to specify the association between division and requseraccount 
models

In your models directory:

division.rb

class Division  ActiveRecord::Base
  has_many :requseraccount
end

class Requseraccount  ActiveRecord::Base
  belongs_to :division
end

And now you can do the following in your controller and view:

@req = Requseraccount.find(:all, :include = :division)
@req.division.name # division_name

You can read more about it at http://guides.rubyonrails.org/. And about 
associations in http://guides.rubyonrails.org/association_basics.html

Regards


Michael R wrote:
 Hello,
 
 I am attempting to display data in the requseraccount form, from the
 divisions table.
 
 For example: I have a division_id field in requseraccount that works
 great. No issues getting this populated from my create form. The
 problem is that I don't want to display the id when showing the form.
 I want to display the division_name, which is in the division table.
 
 Here is a copy of my code
 requseraccounts_controller.rb and schema.rb: http://dpaste.com/35716/
 requseraccoutns: show.html.erb:  http://dpaste.com/35717/
 SQL Query: http://dpaste.com/35725/
 
 I get the following error when I try the above code:
 
  ActiveRecord::RecordNotFound in RequseraccountsController#show
 
Couldn't find Division with ID=8
 
 Which makes sense, since it is trying to do a query WHERE
 division_id=8. I need the query to use requseaccount.divisions_id
 (which is 2) and not requseraccount.id (which is 8).
 
 Any advice would be much appreciated.
 
 Michael

-- 
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: Not quite a rails question but can anyone advise?

2009-04-20 Thread Bharat

That is why I have put it into my /etc/bash.bashrc file since it is
common to all users.

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



[Rails] User defined model and validations?

2009-04-20 Thread rs

I am trying to wrap my head around an idea and would appreciate any
input from rails geniuses out there

I would like to allow an admin user to define data that should be in a
template, and then allow regular users to create instances of this
template and have it validated. ie:

- Template would have name, files and then x many fields of say Text
max length 20 chars, Image size 50x50, Text 10 chars, not
required etc.
- After the template is defined, end user would load it and save
implementations of that template.

The template would be easy to create say template has_many
template_fields.  But how can I load this template, validate it's data
and save the instances in another table(s)?

This would be similar to say allowing the admin to define their own
forms/fields/validations in the database, then saving instances of
these forms.  It seems like this would be a fairly common problem, any
ideas on this?  Is there some type of plugin that might help?

Thanks for any help

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



[Rails] Re: Not quite a rails question but can anyone advise?

2009-04-20 Thread Gavin

Actually - scrap that

I just tried adding ENV['LD_LIBRARY_PATH']=/usr/local/lib:#{ENV
['LD_LIBRARY_PATH']}
to the environment.rb file

This doesn't seem to work

I also added puts ENV['LD_LIBRARY_PATH'] to see if it recognised
LD_LIBRARY_PATH

This returned nil

Any ideas on how I can access this from the environment.rb file?

Also, could you please explain why adding the path to .bash_profile is
not best practice?  This seems to do the trick, at least through the
console.

Thanks

On Apr 20, 1:28 am, Perry Smith rails-mailing-l...@andreas-s.net
wrote:
 Gavin Morrice wrote:
  added

  export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

  to my .bash_profile file

  Seems to have done the trick.

  :)

 I'd revisit that if I were you.  In the final deployment, you are likely
 going to run the server as someone other than you.  And, the .profile is
 not always pulled in either.

 Before the require, I'd try putting:

 ENV['LD_LIBRARY_PATH']=/usr/local/lib:#{ENV['LD_LIBRARY_PATH']}

 Perhaps put it in environment.rb

 --
 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: Not quite a rails question but can anyone advise?

2009-04-20 Thread Gavin

Perry - didn't realize I could set the environment variable in my app
like that

That's a great help - thanks

-:)

On Apr 20, 1:28 am, Perry Smith rails-mailing-l...@andreas-s.net
wrote:
 Gavin Morrice wrote:
  added

  export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

  to my .bash_profile file

  Seems to have done the trick.

  :)

 I'd revisit that if I were you.  In the final deployment, you are likely
 going to run the server as someone other than you.  And, the .profile is
 not always pulled in either.

 Before the require, I'd try putting:

 ENV['LD_LIBRARY_PATH']=/usr/local/lib:#{ENV['LD_LIBRARY_PATH']}

 Perhaps put it in environment.rb

 --
 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] Procesos en background

2009-04-20 Thread Jose vicente Ribera pellicer

Muy buenas, estoy interesado en realizar ciertas tareas de mi aplicacion
en un segundo plano, como por ejemplo la eleccion del usuario del dia.
He estado informandome de como funciona cron y las distintas
herramientas de las que dispone Rails para que este ejecute las
distintas tareas que programamos en el crontab.

Por lo que he leido una opcion es hacer que cron ejecute una rake task
cada cierto tiempo (el que le digamos en el crontab) y en cada task
escribir lo que queremos que se ejecute. Pero por otra parte he visto
que rails
ofrece otra serie de herramientas como puede ser script/runner que
permite ejecutar un metodo de un modelo de la siguiente forma:

./script/runner -e production “Modelo.metodo”

Algo que me parece realmente atractivo dado su sencillez. El problema es
que a la hora de editar el crontab me surgen una serie de dudas (la idea
es recalcular el usuario cada 6 horas) ya que nunca lo he
usado.Navegando he podido observar como es la estructura del crontab:


* *   *   **  command to be executed
- ----
| | | | |
| | | | +- day of week (0 - 6) (Sunday=0)
| | | +--- month (1 - 12)
| | +- day of month (1 - 31)
| +--- hour (0 - 23)
+- min (0 - 59)



Me gustaria que alguien me comentara si la sigueinte liena seria valida
para mi proposito:

* 0-6-12-18 * * * /usr/local/bin/ruby
~/NOMBRE_DE_MI_APLICACION/script/runner -e production 'Modelo.metodo'




Espero que alguien que tenga experiencia editando el crontab me saque de
dudas.

Un saludo
-- 
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: xxx.valid? still true after xxx.errors.add(...)?

2009-04-20 Thread Joshua Muheim

Frederick Cheung wrote:
 On Apr 20, 10:26�am, Joshua Muheim rails-mailing-l...@andreas-s.net
 wrote:
 body: , created_at: nil, updated_at: nil, commentable_type:
 @errors={base=[Captcha wurde nicht korrekt eingegeben]}

 Why the heck does ActiveRecord remove my custom errors when calling
 .valid???
 
 Calling valid? recomputes the errors (there's no difference at the end
 of the day between an error you added yourself and one from a 'normal'
 validations. If you want to add errors yourself you should be doing so
 from a validation
 
 Fred

OK, Thanks for the explanation :-)
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Problems upgrading from 2.2.2 to 2.3.2 - uninitialized constant ActionController::Failsafe (Nam

2009-04-20 Thread dkam

Does anyone have any ideas what causes the uninitialized constant
ActionController::Failsafe error?  Anyone else seen this?

Note - it's not the uninitialized constant ActionController error
caused by not renaming application.rb to application_controller.rb

Cheers,
Dan

On Apr 19, 8:31 pm, dkam daniel.mi...@gmail.com wrote:
 Thanks for the suggestion Fernando, but that doesn't seem to be the
 problem.

 $ ls -trlh app/controllers/
 total 32
 -rw-r--r--  1 dkam  dkam   890B 15 Apr 22:56 application_controller.rb
 -rw-r--r--  1 dkam  dkam    11K 15 Apr 23:00 books_controller.rb

 Any other thoughts?

 On Apr 19, 7:59 pm, Fernando Perez rails-mailing-l...@andreas-s.net
 wrote:

  rename application.rb to application_controller.eb, and next time read
  the changelog.
  --
  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: Testing and SQL views.

2009-04-20 Thread Tim Uckun


 The only code I can see that affects triggers is in the original
 PostgreSQLAdapter#disable_referential_integrity method. It disables
 triggers during a block and re-enables them afterwards. As far as I
 remember, this is used to load fixtures while temporarily suspending the
 triggers. As fixture files are loaded one by one without regard for
 foreign keys, the temporarily violated constraints would cause an
 exception. I don't think the behavior you're seeing is related to views


Yes that's where the problem occurs. That code iterates over the tables
collection. The problem is that you have alias_method_chain on tables which
returns the views as well as the tables and of course the code fails when it
hits a view.

I commented out the alias method chain line and it works.  I hope I didn't
break something else.




  Do I have to make my models which derive from view inherit from
  AR:View? is

 No, that's just for convenience if you like to re-use associations from
 other models.


Ah. Ok 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] application.html.erb problem

2009-04-20 Thread Preethi Sivakumar

Hi,
This may be a silly question to ask. But as performance issues start
popping up I had no other go other than searching for a solution.
I've application.html.erb where i've defined the layout of my whole
project, where i've so many db calls and everything which is a one time
call that must happen for the whole layout.
In the main area i've

   %= yield %

I want only this part to be refreshed/changed whenever i go back and
forth of the pages, but the problem is, the whole page is getting
refreshed everytime which is consuming hell a lot of time as i'm doing
so many db calls for the common layout.

How to achieve my requirement and improve the performance?
And if someother tips are there the improve the performance in ruby on
rails
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: application.html.erb problem

2009-04-20 Thread Gavin

You shouldn't be making database calls from the view.
If you're making calls for the application layout then I'd add these
to the application controller and call them with a before_filter
(anyone know a better way ?)

If the objects you are calling are the same from one page to the next
you could try using an or equals

so instead of always calling
@current_user = User.find session[:user_id]

you could write @current_user ||= User.find session[:user_id]

This should mean that the database call is only made if @current_user
is nil

does that help?

On Apr 20, 1:33 pm, Preethi Sivakumar rails-mailing-l...@andreas-
s.net wrote:
 Hi,
 This may be a silly question to ask. But as performance issues start
 popping up I had no other go other than searching for a solution.
 I've application.html.erb where i've defined the layout of my whole
 project, where i've so many db calls and everything which is a one time
 call that must happen for the whole layout.
 In the main area i've

                    %= yield %

 I want only this part to be refreshed/changed whenever i go back and
 forth of the pages, but the problem is, the whole page is getting
 refreshed everytime which is consuming hell a lot of time as i'm doing
 so many db calls for the common layout.

 How to achieve my requirement and improve the performance?
 And if someother tips are there the improve the performance in ruby on
 rails
 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: application.html.erb problem

2009-04-20 Thread Wouter de Bie

Gavin Morrice wrote:
 You shouldn't be making database calls from the view.
 If you're making calls for the application layout then I'd add these
 to the application controller and call them with a before_filter
 (anyone know a better way ?)
 
 If the objects you are calling are the same from one page to the next
 you could try using an or equals
 
 so instead of always calling
 @current_user = User.find session[:user_id]

Instance variables (@current_user) don't survive from request to 
request, so a lookup will be done for every request (in other words, 
from one page to the next). You could save these objects in your session 
and if you store sessions in memcached, things will speed up and no 
queries to the db will be needed.
To speed up things, caching is a good thing. There are loads of 
tutorials about this and it caveats.
-- 
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: application.html.erb problem

2009-04-20 Thread Gavin

you're right Wouter- that was dumb of me

On Apr 20, 2:05 pm, Wouter de Bie rails-mailing-l...@andreas-s.net
wrote:
 Gavin Morrice wrote:
  You shouldn't be making database calls from the view.
  If you're making calls for the application layout then I'd add these
  to the application controller and call them with a before_filter
  (anyone know a better way ?)

  If the objects you are calling are the same from one page to the next
  you could try using an or equals

  so instead of always calling
  @current_user = User.find session[:user_id]

 Instance variables (@current_user) don't survive from request to
 request, so a lookup will be done for every request (in other words,
 from one page to the next). You could save these objects in your session
 and if you store sessions in memcached, things will speed up and no
 queries to the db will be needed.
 To speed up things, caching is a good thing. There are loads of
 tutorials about this and it caveats.
 --
 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: Not quite a rails question but can anyone advise?

2009-04-20 Thread Wouter de Bie

Gavin Morrice wrote:
 Actually - scrap that
 
 I just tried adding ENV['LD_LIBRARY_PATH']=/usr/local/lib:#{ENV
 ['LD_LIBRARY_PATH']}
 to the environment.rb file
 
 This doesn't seem to work
 
 I also added puts ENV['LD_LIBRARY_PATH'] to see if it recognised
 LD_LIBRARY_PATH

I think that LD_LIBRARY_PATH is not loaded by the application itself, 
but by it's loader (part of the operating system). Setting this variable 
when the application is already started doesn't work. The loader should 
be instructed to load certain libs which (afaik) can only be done by 
setting the variable before you start the app. This can be done by 
setting it from a .bashrc or .profile (depending on your shell). Note 
that these scripts are only used when starting a login shell. A better 
way would be to create a shell script that loads the libs first and then 
starts your server.

 Any ideas on how I can access this from the environment.rb file?
 
 Also, could you please explain why adding the path to .bash_profile is
 not best practice?  This seems to do the trick, at least through the
 console.

If it works, it works :) But if you deploy it under a different user, it 
breaks. E.g. if you deploy it with phusion passenger and apache, the 
user that runs apache should have the path set. You could set this 
globally in /etc/ld.so.conf.
-- 
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: Not quite a rails question but can anyone advise?

2009-04-20 Thread Perry Smith

Wouter de Bie wrote:
 Gavin Morrice wrote:
 Actually - scrap that
 
 I just tried adding ENV['LD_LIBRARY_PATH']=/usr/local/lib:#{ENV
 ['LD_LIBRARY_PATH']}
 to the environment.rb file
 
 This doesn't seem to work
 
 I also added puts ENV['LD_LIBRARY_PATH'] to see if it recognised
 LD_LIBRARY_PATH
 
 I think that LD_LIBRARY_PATH is not loaded by the application itself, 
 but by it's loader (part of the operating system). Setting this variable 
 when the application is already started doesn't work. The loader should 
 be instructed to load certain libs which (afaik) can only be done by 
 setting the variable before you start the app. This can be done by 
 setting it from a .bashrc or .profile (depending on your shell). Note 
 that these scripts are only used when starting a login shell. A better 
 way would be to create a shell script that loads the libs first and then 
 starts your server.
 
 Any ideas on how I can access this from the environment.rb file?
 
 Also, could you please explain why adding the path to .bash_profile is
 not best practice?  This seems to do the trick, at least through the
 console.
 
 If it works, it works :) But if you deploy it under a different user, it 
 breaks. E.g. if you deploy it with phusion passenger and apache, the 
 user that runs apache should have the path set. You could set this 
 globally in /etc/ld.so.conf.

LD_LIBRARY_PATH may not be resampled each time a library is loaded.  I'm 
not sure.  The loader uses it but it gets it from the processes 
environment.  The question is when.

The definitive test is does it work after a reboot and the application 
is automatically deployed by whatever scripts and daemons deploy it.

As mentioned, there is usually a script involved somewhere in that 
process.  I would add it to that script and keep that script somewhere 
in the project (under the project's SCM) so they are tied together. 
The problem you are trying to solve by doing this is to leave yourself 
bread crumbs so when it breaks again in the future, you can retrace your 
steps and remember Oh yea! I need to change my load path

HTH
-- 
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: application.html.erb problem

2009-04-20 Thread Preethi Sivakumar

Gavin Morrice wrote:
 You shouldn't be making database calls from the view.
 If you're making calls for the application layout then I'd add these
 to the application controller and call them with a before_filter
 (anyone know a better way ?)
 
 If the objects you are calling are the same from one page to the next
 you could try using an or equals
 
 so instead of always calling
 @current_user = User.find session[:user_id]
 
 you could write @current_user ||= User.find session[:user_id]
 
 This should mean that the database call is only made if @current_user
 is nil
 
 does that help?
 
 On Apr 20, 1:33?pm, Preethi Sivakumar rails-mailing-l...@andreas-

Thanks for your response.
But, Am not making any db calls from view. I've helpers for everything 
which renders some tabs for user depending on his view. The queries for 
fetching the permissions that the person has and everything is fectched 
from db everytime the page is loaded even though that part of the layout 
is static once it is fectched for the first time. It gets refreshed 
everytime. That is the problem. i want only part of my page to be 
refreshed and other parts to remain static once loaded. How to achieve 
that?

-- 
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: application.html.erb problem

2009-04-20 Thread Frederick Cheung



On Apr 20, 2:37 pm, Preethi Sivakumar rails-mailing-l...@andreas-
s.net wrote:

 Thanks for your response.
 But, Am not making any db calls from view. I've helpers for everything
 which renders some tabs for user depending on his view. The queries for
 fetching the permissions that the person has and everything is fectched
 from db everytime the page is loaded even though that part of the layout
 is static once it is fectched for the first time. It gets refreshed
 everytime. That is the problem. i want only part of my page to be
 refreshed and other parts to remain static once loaded. How to achieve
 that?


You could either avoid traditional navigation and use ajax to update
bits of the page as required or use fragment cacheing to cache the
bits of html that are expensive to render or cache the data that sits
behind that.

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: Testing and SQL views.

2009-04-20 Thread Michael Schuerig

On Monday 20 April 2009, Tim Uckun wrote:
  The only code I can see that affects triggers is in the original
  PostgreSQLAdapter#disable_referential_integrity method. It disables
  triggers during a block and re-enables them afterwards. As far as I
  remember, this is used to load fixtures while temporarily
  suspending the triggers. As fixture files are loaded one by one
  without regard for foreign keys, the temporarily violated
  constraints would cause an exception. I don't think the behavior
  you're seeing is related to views

 Yes that's where the problem occurs. That code iterates over the
 tables collection. The problem is that you have alias_method_chain on
 tables which returns the views as well as the tables and of course
 the code fails when it hits a view.

Indeed, that had escaped my tests. I've pushed an updated version 
version to github.

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


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



[Rails] Re: Multiple log entries when using Rails.cache

2009-04-20 Thread Rudi W.

I've narrowed it down to situations when memcache store is used.

I think somehow the @logger_off property in active_supports cache.rb is 
ignored when used with memcache?

Have anybody else experienced something similar?

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

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



[Rails] Re: Problems with Rails and Postgres

2009-04-20 Thread Rafael Roque

Wisccal Wisccal wrote:
 Rafael Roque wrote:
 Hi all,
 
 
 Have you looked at the SQL generated in the log directory?

Yep..

If I grab the sql in the output directly in the pgAdmin and execute it,I 
get the correct result.

-- 
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: segmentation fault from mysql_adapter.rb

2009-04-20 Thread Nicklas Holm

adedip wrote:
 Do you guys think that is a webserver problem? I mean switching from
 webrick to something else .. would I solve it?
 
 On Apr 17, 10:00�am, Divya Mohan rails-mailing-l...@andreas-s.net

I am using Mongrel, so switching to that won't help. This is totaly 
driving me crazy.
-- 
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] current_user in a model observer

2009-04-20 Thread Bharat Ruparel

I need to get the current_user id in my model observers:

Here is the code for current_user in the lib/authentication.rb file:

module Authentication
  def self.included(controller)
controller.send :helper_method, :current_user, :logged_in?,
:has_role?, :is_admin?
  end

  def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
  end
  ...
end

Here is the propsect_observer.rb file in models directory which needs
it:

class ProspectObserver  ActiveRecord::Observer

  def after_update(prospect)
prospect.comments.create(:content = @comment_text, :admin_only =
@admin_only,
  :commenter_id = current_user.id) if @comment_text
  end

end

current_user is not recognized here.  I could include the module in the
observer, but that is bad(?).  Any suggestion on a good alternative?

Thanks for your time.

Bharat
-- 
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] wrap 2 error fields on one div

2009-04-20 Thread Mikki S.

Hi, help me in my problem plz.

I have a following code:

%= error_message_on guestbook, text %
%= f.label :text, 'Text:' %
%= f.text_area :text %

After validation i get HTML:

div class=formErrorError./div
div class=fieldWithErrorslabel
for=guestbook_textText:/label/div
div class=fieldWithErrors
  textarea id=guestbook_text name=guestbook[text]/textarea
/div

How i can get this:

div class=fieldWithErrors
  div class=formErrorError./div
  label for=guestbook_textText:/label
  textarea id=guestbook_text name=guestbook[text]/textarea
/div
-- 
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: Problem when migrating from rails 2.2.2 to rails 2.3.2 on linux SLES10 + apache 2

2009-04-20 Thread Madchipset

I finally got the solution on the web... Thanks to P. Leonhardt and C
Nolte posts. Here is the workaround :

Copy this file in my_rails_app/config/initializers :

abstract_request.rb

module ActionController
  class AbstractRequest  ActionController::Request
def self.relative_url_root=(path)
  ActionController::Base.relative_url_root=(path)
end
def self.relative_url_root
  ActionController::Base.relative_url_root
end
  end
end

Hope this may help someone else.

Thanks again, my server is working fine now.

On 10 avr, 17:04, Madchipset mad.chip...@voila.fr wrote:
 I have 2railsapps on that server. I didn't get from your answer what
 I shall do on the apache conf file and what I shall do on myrails'
 apps (and in what file : environment.rb ?)

 Thanks.

 On Apr 10, 4:56 pm, Frederick Cheung frederick.che...@gmail.com
 wrote:

  On Apr 10, 2:44 pm, Madchipset mad.chip...@voila.fr wrote:

   I'm using mongrel (1.1.5) andmongrel_cluster(1.0.5) which seem to be
   the last versions. I got a bit deeper in the bug analysis. It's a bit
   trickiest than I first thought. In fact, I have in my cluster config
   file (config/mongrel_cluster.yml) a line : prefix: /my_app_name. If I
   delete this line, the cluster will start alright and I have no more
   errors ! But I need this line so that in my apache conf file, I use
   the Proxy balancer://my_app_name line and the rewrite line
   (RewriteRule ^/my_app_name(.*)$ balancer://my_app_name%{REQUEST_URI}
   [P,QSA,L]).

   It used to work perfectly when I was inrails2.2.2

  Ah - mongrel does

          ActionController::AbstractRequest.relative_url_root = ops
  [:prefix] if ops[:prefix]

  if :prefix is set.

  These days I think you  just set on
  ActionController::Base.relative_url_root

  Give that that's all the prefix option seems to do, you could not pass
  it to mongrel and set it in your app's environment

  Fred

   Any idea ?

   Thanks anyway for your kind help.

   On 9 avr, 23:27, Frederick Cheung frederick.che...@gmail.com wrote:

On Apr 9, 6:17 pm, Madchipset mad.chip...@voila.fr wrote: Thanks a 
lot for your reply Fred. First, I checked with my app : I
 started it fine without the cluster (script/server -e production) and
 it worked nice. Then I created a basic app without any plugin (rails
 test), showing only the standard page Welcome aboard. Again it worked
 fine without the cluster. When I create it (mongrel_rails
 cluster::configure -e production -p 3010 -N 2 -c /my/path/test -a
 127.0.01 --prefix /test) and launch it (mongrel_rails cluster::start)
 then I get the error reported in log/mongrel.3010.log. So wouldn'it be
mongrel_clusterwhich causes theproblem?

Did you try a newer version of mongrel ?

Fred

 On 9 avr, 00:44, Frederick Cheung frederick.che...@gmail.com wrote:

  On Apr 8, 10:16 pm, Madchipset mad.chip...@voila.fr wrote: When 
  I do this migration and I want to launchmongrel_cluster
   (mongrel_rails cluster::start), I get an error :
   ** Starting Mongrel listening at 127.0.0.1:3010
   ** StartingRailswith production environment...
   ** MountingRailsat /test...
   /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
   dependencies.rb:440:in `load_missing_constant': uninitialized 
   constant
   ActionController::AbstractRequest (NameError)
   ..
   No plugins. It's just a basicrailsapp showing only the standard
   index page.

  Definitely sounds like a plugin or monkey patch issue to me -
  AbstractRequest was a class that disappeared inrails2.3. I'd start
  by searching your code for that and see what comes up.

  Fred

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



[Rails] Problem with embedding a SWF player file in page

2009-04-20 Thread Rubio Ramirez

Found a great link
(http://blog.eleventyten.com/2007/6/8/embedding-swf-content-with-ror/)
describing adding Flash content (in my case playerMultipleList.swf) in
a rails webpage.

I've followed the instructions to a T, however the player doesn't
display on the page ... just the words playerMultipleList.swf appear :-(

Everything else is working great after retrofitting the pages to the ROR
framework, but this is one of the most important features.  If you have
experience with this and would kindly share it, I will greatly
appreciate it!

Please see attachment for the code I'm using !

Thanks Rubio

Attachments:
http://www.ruby-forum.com/attachment/3596/sounds.html.erb

-- 
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: current_user in a model observer

2009-04-20 Thread Bharat Ruparel

Forget it.  Bad design.  I am not pursuing this path anymore.
-- 
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: Problem with embedding a SWF player file in page

2009-04-20 Thread chris.reis...@gmail.com

line 8-10 of your file might be what you are seeing.

08 script type=text/javascript src=swfobject.js/script
09 div id=flashPlayer
10   playerMultipleList.swf
11 /div

line 10 is where is displays the name.
line 08 is most likely the problem.  Usually javascripts are in a
javascripts directory.  change that line to this and see if it works:

08 script type=text/javascript src=/javascripts/swfobject.js/
script

I have never used that javascript swfobject.js library before, but my
#1 guess is you are not loading it.

I am also sure there would be a way to play your SWF without needing
the Javascript that would make your life easier  so look into that
also.

Chris Reister
www.cowboyonrails.com



On Apr 20, 8:34 am, Rubio Ramirez rails-mailing-l...@andreas-s.net
wrote:
 Found a great link
 (http://blog.eleventyten.com/2007/6/8/embedding-swf-content-with-ror/)
 describing adding Flash content (in my case playerMultipleList.swf) in
 a rails webpage.

 I've followed the instructions to a T, however the player doesn't
 display on the page ... just the words playerMultipleList.swf appear :-(

 Everything else is working great after retrofitting the pages to the ROR
 framework, but this is one of the most important features.  If you have
 experience with this and would kindly share it, I will greatly
 appreciate it!

 Please see attachment for the code I'm using !

 Thanks Rubio

 Attachments:http://www.ruby-forum.com/attachment/3596/sounds.html.erb

 --
 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] manual access to session data outside of request?

2009-04-20 Thread Jonathan Rochkind

So, given a sessionID, I have need to read and write the session stored
information 'manually', from _outside_ an actual Rails
request/controller.

Readers, I know your first response may be to tell me I don't really
want to do that. Trust me though, I really do, it makes sense for me in
my case.

I know this wouldn't work if you're using the new cookie session storage
mechanism. But if you're using a server-side session storage mechanism,
I'm thinking there must be some reasonable way to do this.  But I'm
having trouble figuring it out.

I've tried looking through the rails source code to see how Rails reads
and write session, but I'm having trouble finding the relevant code. I
also figured, gee, since Rails allows pluggable session storage
architecture, there must be an abstract description of what a session
store must implement, and how to access it, and that might help me --
but I couldn't find that either.

Anyone have any ideas or tips?  I'd like a
session-storage-implementation-agnostic (assuming it's a server-side
method of storage) way to read and write the session hash from outside a
Rails controller.

Jonathan
-- 
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] Gmaps and radio_button

2009-04-20 Thread Luigi Sinatra

Hi all

I'have a problem whit radio_buttons and button_to_remote, when I use
them together with google_maps.
I inserted the gmaps into my project, and then when I click on a
radio_button or a button_to_remote it isn't work properly.

can you help me?
Please
thank's
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: View error, Resource route

2009-04-20 Thread Paul A.

Many thanks, Gavin Morrice.

Thanks to your answer, I had making some modifications to gets this:

% form_tag system_path do %
%= error_messages_for 'system' %
...
%= submit_tag 'Create' %
% end %

After testing this line:
% form_for :system, :url = {:action = :create} do |f| %

it's okay too.
-- 
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: manual access to session data outside of request?

2009-04-20 Thread Frederick Cheung


On 20 Apr 2009, at 17:04, Jonathan Rochkind wrote:


 So, given a sessionID, I have need to read and write the session  
 stored
 information 'manually', from _outside_ an actual Rails
 request/controller.

 Readers, I know your first response may be to tell me I don't really
 want to do that. Trust me though, I really do, it makes sense for me  
 in
 my case.

 I know this wouldn't work if you're using the new cookie session  
 storage
 mechanism. But if you're using a server-side session storage  
 mechanism,
 I'm thinking there must be some reasonable way to do this.  But I'm
 having trouble figuring it out.

 I've tried looking through the rails source code to see how Rails  
 reads
 and write session, but I'm having trouble finding the relevant code. I
 also figured, gee, since Rails allows pluggable session storage
 architecture, there must be an abstract description of what a session
 store must implement, and how to access it, and that might help me --
 but I couldn't find that either.

How it is stored is almost all up to the session store - they need to  
be able to fetch the data for a given session id and store some data  
for a session id.

The details have changed between rails 2.2 and 2.3, in 2.2 it was the  
old cgi interface, in 2.3 it's the new rack interface - you'll need to  
instantiate the appropriate subclass of ActionController::SessionStore

Fred
 Anyone have any ideas or tips?  I'd like a
 session-storage-implementation-agnostic (assuming it's a server-side
 method of storage) way to read and write the session hash from  
 outside a
 Rails controller.

 Jonathan
 -- 
 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] Any plugin to send email asyncronously in the background

2009-04-20 Thread Ajaya Agrawalla

We would like to queue our emails and send them outside of the
application using an external SMTP provider.  Any plugin out there which
will do this for us? I would like to explore before we go all out 
write our own.

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

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



[Rails] Re: Help with Data Warehouse app -- How to display data?

2009-04-20 Thread Marnen Laibow-Koser



On Apr 17, 9:48 pm, Kyle N/a rails-mailing-l...@andreas-s.net
wrote:
 I have a data warehouse application I've been writing and I would like
 to solicit some assistance with how to design it.  Basically, I harvest
 data from a lot of sources and dump them into my database.

 For background on what I'm doing, this data warehouse takes
 HR/Personnel/Company/Organizational data and associates that with User
 Account and Group data from 5 platforms (ie, Active Directory, UNIX,
 others).

 I began first by scaffolding and designing the Models, and then
 importing the data with a Rake task--roughly doing:

 1.) Insert/Update nightly data into Table.
 2.) Flag data that was not in my nightly source data (maybe it was
 deleted?)
 3.) Call method to create relationships (hooks) between these various
 sources.

(Just so you know...3 isn't necessary with Rails.)


 I wrote this in Perl (with mysql) and I displayed this data in a webpage
 by using a set of SQL Views and a meta-table, describing what elements
 of these views is displayed.

I am now somewhat confused.  How were you using Rake with Perl?


 It was not a good solution for a lot of reasons so I decided to redo my
 database and learn Ruby/RoR in the process.
[...]
 All told, I have 17 tables (so, 17 nightly dumps).  A majority of the
 searches are going to be against 3 to 8 of these tables.

 Given all of this, my issues/questions are as follows:

 - I'm really trying to avoid hard coding as much as possible.  Ideally,
 I'd have some kind of admin interface to make changes to how data is
 displayed.  The idea of hard coding each text box for the search fields,
 or the displayed columns, etc... isn't appealing to me.

Check out ActiveScaffold.


 If this really is the best solution, I suppose I can go that route.  The
 nice thing of having my Views in MySQL was that it was easy to map meta
 data to what to display.

Rails will deal with database views.  I don't know that much about how
to work with them, but there's been discussion about them on this
list.


 - I'm trying to figure out how to design this to make it very scalable
 and easy to modify.  Particularly, if two tables have a column that have
 something in common, I'd like to (perhaps) make those into a link to
 each other.

I believe ActiveScaffold will do this easily.


 - As above, I'd also like to add extra functionality.  I setup
 acts_as_revisable in my database and it works very well.  If a user has
 an elevated role, I'd like to have them be able to review the history of
 a record.

 These are pretty lofty goals

No, they're not.

 and this will take some baby steps.  I'm
 still new to Ruby/RoR, but I think it's been hard (so far) to find good
 documentation that addresses some of these issues.  Or maybe I don't
 know the key words or how to approach this the Ruby Way (probably the
 case)?

I think you're overthinking it.  Rails makes what you're talking about
so basic that I don't think most people would bother writing tutorials
on the subject.  Have you started writing this application yet?


 I'd like to use my experiences to do a write-up/tutorial on how to
 address data warehousing problems with RoR (and starting RoR from
 scratch).  If I become good enough, I may eventually attempt a plugin
 for combined data warehousing, versioning, cross-referencing, etc (if I
 still think there's a use for it).

That could be interesting, although things like ActiveScaffold cover a
lot of the same ground.


 I really appreciate everyone's help/advice on the issue.
 --
 Posted viahttp://www.ruby-forum.com/.

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



[Rails] Re: manual access to session data outside of request?

2009-04-20 Thread Jonathan Rochkind

Frederick Cheung wrote:
 The details have changed between rails 2.2 and 2.3, in 2.2 it was the
 old cgi interface, in 2.3 it's the new rack interface - you'll need to
 instantiate the appropriate subclass of ActionController::SessionStore

This helps, thanks. Trying to look through the source and googling, I 
did discover that this changed very much between 2.2 and 2.3, I might 
need to write two versions of my code.

But since there is an abstract model for a session store, it must be 
possible for me to access the session store and read and write session 
info without knowing about the black box internals.

Once I've gotten the appropriate ActionController::SessionStore... what 
the heck do I do with it in order to read or write session data?

Unless the specs for how to write a session store have changed in 2.3, 
it may be my code doesn't need to be different for 2.3. But if it does, 
I can deal with that too.

Still having trouble figuring out what methods to call on a session 
store once I've gotten it to read or write data.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Problems with Rails and Postgres

2009-04-20 Thread Harold

What kind of error do you get, exactly?

On Apr 16, 1:10 pm, Rafael Roque rails-mailing-l...@andreas-s.net
wrote:
 Hi all,

 i have a method that I use in the 'after_save' that is implemented as
 follows:

  def verify
     a =11674
     x =  self.aui_codigo

       reinc =AutoInfracao.find_by_sql(select age((select aui_data_lav
 from tb_aui_auto_infracao where aui_codigo=#{a}),
 (select max(aui_data_lav)from tb_aui_auto_infracao where aui_codigo
 in(select a.aui_codigo from tb_aur_auto_inf_regular a,tb_iau_itens_auto
 i where a.for_cod =(select for_cod from tb_aur_auto_inf_regular where
 aui_codigo=#{a}) and a.lir_codigo=(select lir_codigo from
 tb_aur_auto_inf_regular where aui_codigo = #{a}) and i.inf_codigo =
 (select inf_codigo from tb_iau_itens_auto where aui_codigo = #{a}) and
 a.aui_codigo#{a} and a.aui_codigo = i.aui_codigo

     print reinc[0].age
   end

 the 'a' and the 'x' variables have the same value(11674) and the same
 type(FixNum).Curiously,I can run my query using the 'a' variable,but I
 cannot run it using the 'x' variable.What am I doing wrong?
 --
 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] RJS sporadic error message

2009-04-20 Thread Shandy Nantz

I have this form that allows a user to enter a username and save it,
assocciating your profile with theirs via an id. A list gets updated and
a partial is displayed. The problem is that when I hit the submit button
to this form to make this all happened I (sometimes, but more often then
not) get an RJS error that reads:
  TypeError: Cannot set property 'innerHTML' of bull.
I hot OK and another error pops up giving me this long string of what
appears to be JavaScript or Ajax code?

Main View Code:
div id = update_first align = center
  span class=headerTravel Arranger Pages/spanbr /br /
  b class = table-headerThe profiles for which you are responsible
/bbr /
  hr width = 67%
  div id = travel-managers-users
%= render :partial = 'show_my_users' %
  /div
  hr width = 67%
  br /
  div id = company_users
%= render :partial = 'add_new_profile' %
  /div
/div

Partial - add_new_profile:
% form_remote_tag :url = {:action = 'add_profile_auto', :id =
@user.id },
  :complete = new Effect.Appear('airport'); new
Effect.Pulsate('airport');
  do -%
  bType in username to add to your list: /bbr /
  %= text_field_with_auto_complete :user, :username,
 {:value = '', :size = 45},
 {:url = { :action = auto_complete_for_user_username,
:id = @user.primary_account_id },
  :skip_style = true} %
  %= submit_tag 'Add Name'%
% end -%


Controller code - add_profile_auto:
.
   render :update do |page|
 page.replace_html 'travel-managers-users', :partial =
'show_my_users'
 page.replace_html 'company_users', :partial = 'add_new_profile'
   end
.

Any ideas of why I am getting this error. I am just lost. Like I said I
sometimes get the error and sometimes I don't.

Thanks in advance,

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

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



[Rails] Re: Any plugin to send email asyncronously in the background

2009-04-20 Thread Marko Anastasov

delayed_job [0] is a nice plugin to do things in the background.

  mx.

[0] http://github.com/tobi/delayed_job/tree/master

On Apr 20, 7:02 pm, Ajaya Agrawalla rails-mailing-l...@andreas-s.net
wrote:
 We would like to queue our emails and send them outside of the
 application using an external SMTP provider.  Any plugin out there which
 will do this for us? I would like to explore before we go all out 
 write our own.

 aj
 --
 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: manual access to session data outside of request?

2009-04-20 Thread Frederick Cheung



On Apr 20, 6:13 pm, Jonathan Rochkind rails-mailing-l...@andreas-
s.net wrote:
 Frederick Cheung wrote:
  The details have changed between rails 2.2 and 2.3, in 2.2 it was the
  old cgi interface, in 2.3 it's the new rack interface - you'll need to
  instantiate the appropriate subclass of ActionController::SessionStore

 This helps, thanks. Trying to look through the source and googling, I
 did discover that this changed very much between 2.2 and 2.3, I might
 need to write two versions of my code.

 But since there is an abstract model for a session store, it must be
 possible for me to access the session store and read and write session
 info without knowing about the black box internals.

 Once I've gotten the appropriate ActionController::SessionStore... what
 the heck do I do with it in order to read or write session data?

 Unless the specs for how to write a session store have changed in 2.3,
 it may be my code doesn't need to be different for 2.3. But if it does,
 I can deal with that too.

They did - had to rewrite a lot of that bit of my session store for
2.3

In 2.3 Session stores have to implement a get_session method. The
first argument is just the environment hash that rack gives you -
you'll probably have to fiddle around a bit to workout how much you
have to fake up (maybe nothing at all)

Fred


 Still having trouble figuring out what methods to call on a session
 store once I've gotten it to read or write data.
 --
 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 + Postgres = Bad Idea or Good Idea?

2009-04-20 Thread Marnen Laibow-Koser

Two small quibbles that I thought were just big enough to raise
here...

On Apr 17, 4:30 pm, Bill Sim rails-mailing-l...@andreas-s.net wrote:
 I think we will stick with our current plan, and usePostgresql.  In
 general, it makes me uncomfortable when developers refuse to use one
 tool or another.

It depends on the developer.  Good developers know what they're
talking about, and their preferences can often tell you a lot about a
tool -- and about their development practices -- that you might not
otherwise know.

In other words, if a developer has a *good* reason for refusing to use
something, it may be to your advantage to find out what that reason
is.

  It shouldn't really matter.  It's the architecture
 that really counts.

Perhaps, but in practice that's not really true -- details that are
computationally trivial can make a huge difference to developer
productivity.  That's why we don't typically develop Web apps in C,
although it can be and has been done.

On Apr 17, 9:44 pm, Hassan Schroeder hassan.schroe...@gmail.com
wrote:
[...]
 One thing to consider is that the idea that ActiveRecord just magically
 insulates the developer from understanding the underlying database
 is wishful thinking, once you get past your basic 'hello world' app.

Yes, you have to *understand* the DB, but that often does not require
changes to well-written code.  I have written and maintained complex
applications that were deployed on both mySQL and PostgreSQL, often
simultaneously.  ActiveRecord really *does* insulate the developer
from a lot of DB-specific stuff -- if the developer is smart and
writes DB-neutrally.  (I just took over maintenance of an app where
the developer didn't do that...)

And part of being smart is understanding the underlying DB well
enough to know what's portable and what isn't.


 So if someone knows MySQL well, s/he may not want to put the time
 into learning the gotchas of another DB.  I would charge more just to
 cover the aggravation of using Postgres's god-awful command line
 tools. :-)

I never use the command-line tools, either with PostgreSQL or mySQL.
I don't find either set to be very easy to use...that's what graphical
admin programs are for.

(Maybe if I were a DBA, things would be different.  But I just don't
use the command-line tools often enough to remember syntax between
uses.)

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



[Rails] Re: manual access to session data outside of request?

2009-04-20 Thread Jonathan Rochkind

Frederick Cheung wrote:
 Unless the specs for how to write a session store have changed in 2.3,
 it may be my code doesn't need to be different for 2.3. But if it does,
 I can deal with that too.

 They did - had to rewrite a lot of that bit of my session store for
 2.3
 

Thanks Fred. It actually looks like this would be fairly straightforward 
in 2.3. This blog post provides some hints:

http://devblog.michaelgalero.com/2009/02/03/guide-to-rails-metal/

But my app is not yet working with 2.3 in general, and I'd like it to 
work with both. And in pre-2.3, it seems, from looking at the Rails 
source, that it would be REALLY tricky to do this.

So now I'm thinking of another option. One would be storing this 
information in my own database models, keyed by Rails SessionID.  But 
once I've done that, I've kind of duplicated the ActiveRecordStore. So 
another option would be writing my code to assume that the session store 
is an ActiveRecordStore -- if you make this assumption, instead of 
trying to write store-agnostic code, then accessing the info in pre-2.3 
looks to be more do-able.  And I could write code that works with either 
pre 2.3 or 2.3.

Not sure what I'm going to do really. I need something keyed on 
sessionID that is accessible outside a Rails request, as well as inside 
a Rails request.

If anyone else has ideas, feel free to share.

Jonathan
-- 
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: Ruby + Postgres = Bad Idea or Good Idea?

2009-04-20 Thread Hassan Schroeder

On Mon, Apr 20, 2009 at 11:16 AM, Marnen Laibow-Koser mar...@marnen.org wrote:

 Yes, you have to *understand* the DB, but that often does not require
 changes to well-written code.  I have written and maintained complex
 applications that were deployed on both mySQL and PostgreSQL, often
 simultaneously.  ActiveRecord really *does* insulate the developer
 from a lot of DB-specific stuff -- if the developer is smart and
 writes DB-neutrally.

When you use *standard AR associations* -- no custom SQL at all --
and it runs on one DB and fails on another, I'd say you need to know
a little more about those DBs. Wouldn't you?  :-)

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

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



[Rails] restful_authentication: 3 unit tests break!

2009-04-20 Thread Joshua Muheim

Hi all

I have installed restful_authentication. However, I didn't active the
email-verification option in the first way, so I tried to activate it
manually some time later. But now I have problems with my application
and I'm trying to solve them bit by bit.

First of all, my unit tests don't work:

  1) Failure:
test_should_initialize_activation_code_upon_creation(UserTest)
[./test/unit/user_test.rb:18:in
`test_should_initialize_activation_code_upon_creation'
 
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/testing/setup_and_teardown.rb:33:in
`__send__'
 
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/testing/setup_and_teardown.rb:33:in
`run']:
nil expected to not be nil.

  2) Failure:
test_should_unsuspend_user_to_active_state(UserTest)
[./test/unit/user_test.rb:130:in
`test_should_unsuspend_user_to_active_state'
 
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/testing/setup_and_teardown.rb:33:in
`__send__'
 
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/testing/setup_and_teardown.rb:33:in
`run']:
false is not true.

  3) Failure:
test_suspended_user_should_not_authenticate(UserTest)
[./test/unit/user_test.rb:123:in
`test_suspended_user_should_not_authenticate'
 
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/testing/setup_and_teardown.rb:33:in
`__send__'
 
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/testing/setup_and_teardown.rb:33:in
`run']:
#User id: 1, login: quentin, email: quen...@example.com,
crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1, salt:
7e3041ebc2fc05a40c60028e2c4901a81035d3cd, created_at: 2009-04-15
15:13:00, updated_at: 2009-04-20 15:13:01, remember_token: nil,
remember_token_expires_at: nil, first_name: Quentin, last_name:
Tarantino, activation_code: nil, state: suspended, activated_at:
nil, deleted_at: nil expected to be != to
#User id: 1, login: quentin, email: quen...@example.com,
crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1, salt:
7e3041ebc2fc05a40c60028e2c4901a81035d3cd, created_at: 2009-04-15
15:13:00, updated_at: 2009-04-20 15:13:01, remember_token: nil,
remember_token_expires_at: nil, first_name: Quentin, last_name:
Tarantino, activation_code: nil, state: suspended, activated_at:
nil, deleted_at: nil.

43 tests, 83 assertions, 3 failures, 0 errors
rake aborted!
Command failed with status (1):
[/System/Library/Frameworks/Ruby.framework/...]

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

Sadly I have no idea how to fix them... what could be wrong? My user
model looks the following:

require 'digest/sha1'
class User  ActiveRecord::Base
  # Virtual attribute for the unencrypted password
  attr_accessor :password

  validates_presence_of :login,
:email,
:first_name,
:last_name
  validates_presence_of :password,   :if =
:password_required?
  validates_presence_of :password_confirmation,  :if =
:password_required?
  validates_length_of   :password, :within = 4..40, :if =
:password_required?
  validates_confirmation_of :password,   :if =
:password_required?
  validates_length_of   :login,:within = 3..40
  validates_length_of   :email,:within = 3..100
  validates_uniqueness_of   :login, :email, :case_sensitive = false
  before_save :encrypt_password

  has_many :comments,
:dependent = :destroy

  has_many :blogs,
:dependent = :destroy

  # prevents a user from submitting a crafted form that bypasses
activation
  # anything else you want your user to change should be added here.
  attr_accessible :login,
:email,
:first_name,
:last_name,
:password,
:password_confirmation

  acts_as_state_machine :initial = :pending
  state :passive
  state :pending, :enter = :make_activation_code
  state :active,  :enter = :do_activate
  state :suspended
  state :deleted, :enter = :do_delete

  event :register do
transitions :from = :passive, :to = :pending, :guard = Proc.new
{|u| !(u.crypted_password.blank?  u.password.blank?) }
  end

  event :activate do
transitions :from = :pending, :to = :active
  end

  event :suspend do
transitions :from = [:passive, :pending, :active], :to =
:suspended
  end

  event :delete do
transitions :from = [:passive, :pending, :active, :suspended], :to
= :deleted
  end

  event :unsuspend do
transitions :from = :suspended, :to = :active,  :guard = Proc.new
{|u| !u.activated_at.blank? }
transitions :from = :suspended, :to = :pending, :guard = Proc.new
{|u| !u.activation_code.blank? }
transitions :from = :suspended, :to = :passive
  end

  # Authenticates a user by their login name and unencrypted password.
Returns the user or nil.
  def self.authenticate(login, password)
u = find_by_login(login) # need to get the salt
u  u.authenticated?(password) ? u : nil
  end

  # Encrypts some data with the salt.
  def self.encrypt(password, salt)

[Rails] Re: Blackbook

2009-04-20 Thread Trevor Evans

I actually got this exact same error with gmail. I was wondering if you
ever found a solution?
-- 
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: Not quite a rails question but can anyone advise?

2009-04-20 Thread Wouter de Bie

Perry Smith wrote:
 LD_LIBRARY_PATH may not be resampled each time a library is loaded.  I'm 
 not sure.  The loader uses it but it gets it from the processes 
 environment.  The question is when.

I read some articles about this and ld.so (normally linked by libc.so) 
calls_dl_init_paths() when it's initializing. After this, there are no 
more calls to this function. The input is drawn from the environment and 
/etc/ld.so.conf. There's not a lot to do about this, other than setting 
it before.
In the question above, I think it shouldn't be a problem to include 
/usr/local/lib in your /etc/ld.so.conf (you need root access of course).

Another dirty hack might be to set the LD_LIBRARY_PATH and then fork. 
The new process should load the newly set path, but I'm not sure if you 
want to fork a complete rails stack (I've done it in the past, but 
doesn't feel very right).


-- 
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: cycle(...) - is there some sort of only_first_time(...)?

2009-04-20 Thread Jason Arora

I would prefer to use each_with_index:

@records.each_with_index do |r, i|
  first record: #{r.name} if i == 0
  just another record: #{r.name}
end

On Apr 19, 5:27 pm, Ryan Waldron r...@erebor.com wrote:
 It might be instructive to look at the code for the cycle method.  It
 actually creates an object and calls its to_s method each time you call
 'cycle'.

 You could do a similar thing.  Create a small class with a 'to_s' method
 that returns something the first time, but nothing thereafter.

 class Once
   def initialize(first_value)
     @value = first_value
   end

   def reset
     @value = ''
   end

   def to_s
     value = @value
     reset
     return value
   end
 end

 Stick that in lib/ or include it some other way. Then you can call cycle,
 but pass your object as a single argument to cycle (cycle doesn't require
 actually more than one param, though you could pass your object as both
 params, or just pass it as the first param and '' as the second):

 % label_once = Once.new('_bar') %

   tr class='foo%= cycle(label_once) %'

 You'll get

   tr class='foo_bar'
   ...
   tr class='foo'
   ...
   tr class='foo'

 Might be a bit overkill, but kind of fun. :)

 On Sun, Apr 19, 2009 at 5:52 PM, Joshua Muheim 

 rails-mailing-l...@andreas-s.net wrote:

   Just write one:

   in a helper:
      def only_first_time(what)
        first_time = @previous_what.nil?
       �...@previous_what ||= what
        what if first_time
      end

  Thanks, but that's not very versatile. I could only use it once. AFAIK I
  can use cycle() wherever I want, so I'd like the helper to be somehow
  dependant from where it has been called. Is this possible?

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



[Rails] Re: redirect_to results in syntax error for !DOCTYPE HTML...

2009-04-20 Thread Tom Ha

Thanks for your (actually super-quick) reply, Fred!

To paraphrase it (correct me if I'm wrong):

Whenever an Ajax request is sent (i.e. using submit_to_remote) the 
rendering part in the controller can NOT use redirect_to :action = 
... or render :action = 

Rendering the response can in this case only be done using:

render :update do |page|
  page.replace_html 'whatever', :partial = 'whatever'
end

redirect_to and render can only be used after regular requests.
-- 
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: manual access to session data outside of request?

2009-04-20 Thread Frederick Cheung


On 20 Apr 2009, at 19:31, Jonathan Rochkind wrote:


 Frederick Cheung wrote:
 Unless the specs for how to write a session store have changed in  
 2.3,
 it may be my code doesn't need to be different for 2.3. But if it  
 does,
 I can deal with that too.

 They did - had to rewrite a lot of that bit of my session store for
 2.3


 Thanks Fred. It actually looks like this would be fairly  
 straightforward
 in 2.3. This blog post provides some hints:

 http://devblog.michaelgalero.com/2009/02/03/guide-to-rails-metal/

 But my app is not yet working with 2.3 in general, and I'd like it to
 work with both. And in pre-2.3, it seems, from looking at the Rails
 source, that it would be REALLY tricky to do this.

2.2 is a bit easier actually -

Struct.new('FakeSession', :session_id)
fake_cgi_session = Struct::FakeSession.new('some session id')

session = WhateverSessionStoreClass.new(fake_cgi_session)
session.restore

Fred

 So now I'm thinking of another option. One would be storing this
 information in my own database models, keyed by Rails SessionID.  But
 once I've done that, I've kind of duplicated the ActiveRecordStore. So
 another option would be writing my code to assume that the session  
 store
 is an ActiveRecordStore -- if you make this assumption, instead of
 trying to write store-agnostic code, then accessing the info in  
 pre-2.3
 looks to be more do-able.  And I could write code that works with  
 either
 pre 2.3 or 2.3.


If you assume ActiveRecord store it's pretty easy. find the row with  
the right session id, data is right there.

Fred

 Not sure what I'm going to do really. I need something keyed on
 sessionID that is accessible outside a Rails request, as well as  
 inside
 a Rails request.

 If anyone else has ideas, feel free to share.

 Jonathan
 -- 
 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: redirect_to results in syntax error for !DOCTYPE HTML...

2009-04-20 Thread Frederick Cheung


On 20 Apr 2009, at 20:07, Tom Ha wrote:


 Thanks for your (actually super-quick) reply, Fred!

 To paraphrase it (correct me if I'm wrong):

 Whenever an Ajax request is sent (i.e. using submit_to_remote) the
 rendering part in the controller can NOT use redirect_to :action =
 ... or render :action = 

 Rendering the response can in this case only be done using:

 render :update do |page|
  page.replace_html 'whatever', :partial = 'whatever'
 end

 redirect_to and render can only be used after regular requests.

It depends on whether link_to_remote, submit_to_remote etc... have  
been passed the :update option.

- if they have then they are updating an element on the page and you  
need to generating a normal html fragment
- if they are not then they are expecting javascript, so using  
render :update and so on is compulsory.

Fred


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

 


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



[Rails] baffled with form_for

2009-04-20 Thread harm

I have a simple User form with a simple Usercontroller.
The 'edit' action looks like:
  def edit
@user = current_user
  end

In the view:
% form_for(@user) do |f| %
blah blah
% end %

What it generates is:
  form action=/user.%23%3Cuser:0x34a498c%3E class=edit_user
id=edit_user_196 method=post
  div style=margin:0;padding:0input name=_method type=hidden
value=put /
  input class=inline id=user_login name=user[login] size=30
type=text /.
  input src=/images/buttons/registreren.png?1239978560
type=image /
  /form

How does that form 'action' field becomes so b0rked?

Running Rails 2.3.2

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



[Rails] Re: manual access to session data outside of request?

2009-04-20 Thread Jonathan Rochkind

Frederick Cheung wrote:
 On 20 Apr 2009, at 19:31, Jonathan Rochkind wrote:
 2.2 is a bit easier actually -

I must admit that my app is still in Rails 2.1 now, for annoying reasons 
that will make everyone tell me I'm doing Rails wrong again.

 If you assume ActiveRecord store it's pretty easy. find the row with
 the right session id, data is right there.

Yeah, I think that's the way to go for now. I'd like to use 
ActiveRecordStore's own methods to serialize/unserialize the data, to 
not have my code depending on certain assumptions about precisely how 
ActiveRecordStore serializes, but I think that's do-able too.

Thanks for helping me think this through.

Jonathan

-- 
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] Nested params issue with Rack 1.0 / Unable to freeze Rails

2009-04-20 Thread Olaf S.

Hi,

I have a very strange issue. I upgraded my Application to Rails 2.3.2
without any problems, then freezed it to vendor/rails and worked through
all my specs after I also upgraded Rspec to 1.2.4. At some point (I
cannot exactly tell you when) nested parameters didn't work anymore.

That means the server receives something like:

{ post[body] = data }

instead of

{ post = { body = data } }

This issue seems to be known as the Rails 2.3.2 / 2.3.2.1 confusion.

So I worked through all the forums, deinstalled the gem rack-0.9.1 and
checked that I have the commit 39ff550fa88da9a22d8c21ca872f5e4d0d83f8d4
(http://github.com/rails/rails/commit/39ff550fa88da9a22d8c21ca872f5e4d0d83f8d4)
That means the bundled rack-1.0 should be loaded, at least my rack.rb
reads on line 6

$:.unshift(File.expand_path(File.dirname(FILE)))

Still the problem persists and I don't know exactly how to fix this.

I also tried

$ sudo rake rails:freeze:edge RELEASE=2.3.2.1

But all I get is:

cd vendor Downloading Rails from http://dev.rubyonrails.org/archi...
rake aborted! Operation timed out - connect(2)

I cannot call or reach http://dev.rubyonrails.org , not even in my
browser. Any ideas?

Here are two related lighthouse tickets which didn't solve my problem:

https://rails.lighthouseapp.com/projects/8994/tickets/2259-params-hash-issues

https://rails.lighthouseapp.com/projects/8994/tickets/2255-bundled-rack-10-doesnt-loaded-first-in-rails-232

Thank you for any hints / ideas / solutions!
-- 
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: redirect_to results in syntax error for !DOCTYPE HTML...

2009-04-20 Thread Tom Ha

Ok, 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: restful_authentication: 3 unit tests break!

2009-04-20 Thread Fernando Perez

 I guess it has something to do with acts_as_state_machine?

Yes. Don't you read the source code of your plugins before using them? 
That's bold.
-- 
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: manual access to session data outside of request?

2009-04-20 Thread Frederick Cheung



On Apr 20, 8:11 pm, Jonathan Rochkind rails-mailing-l...@andreas-
s.net wrote:
 Frederick Cheung wrote:
  On 20 Apr 2009, at 19:31, Jonathan Rochkind wrote:
  2.2 is a bit easier actually -

 I must admit that my app is still in Rails 2.1 now, for annoying reasons
 that will make everyone tell me I'm doing Rails wrong again.

the pre 2.2 way should work way back to rails 1.1, and possibly even
further back.

Fred
  If you assume ActiveRecord store it's pretty easy. find the row with
  the right session id, data is right there.

 Yeah, I think that's the way to go for now. I'd like to use
 ActiveRecordStore's own methods to serialize/unserialize the data, to
 not have my code depending on certain assumptions about precisely how
 ActiveRecordStore serializes, but I think that's do-able too.



 Thanks for helping me think this through.

 Jonathan

 --
 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 + Postgres = Bad Idea or Good Idea?

2009-04-20 Thread TheRailsWayOrTheHighway

Here's a quote from the February issue of Linux Journal (p69) that
might be of interest to you:  I use PostgreSQL as my database, as
I've decided to give PostgreSQL a go having read Reuven Lerner's
excellent series of articles comparing PostgreSQL to MySQL (see the
April, May and June 2007 issues of LJ.)

Especially significant, now that Oracle will own MySQL.

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



[Rails] Re: Any plugin to send email asyncronously in the background

2009-04-20 Thread David Knorr



On 20 Apr., 19:02, Ajaya Agrawalla rails-mailing-l...@andreas-s.net
wrote:
 We would like to queue our emails and send them outside of the
 application using an external SMTP provider.  Any plugin out there which
 will do this for us? I would like to explore before we go all out 
 write our own.

 aj

You can also take a look at this episode of Railscasts:
http://railscasts.com/episodes/129-custom-daemon Making your own
daemon to run in the background is surprisingly easy.

--
Best regards,
David Knorr
http://twitter.com/perplect

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



[Rails] Re: restful_authentication: 3 unit tests break!

2009-04-20 Thread Joshua Muheim

Fernando Perez wrote:
 I guess it has something to do with acts_as_state_machine?
 
 Yes. Don't you read the source code of your plugins before using them? 
 That's bold.

Thanks for your very helpful answer. ;-)
-- 
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: manual access to session data outside of request?

2009-04-20 Thread Jonathan Rochkind

Frederick Cheung wrote:
 the pre 2.2 way should work way back to rails 1.1, and possibly even
 further back.

Huh, then I might as well do it the actual legit way, and I guess I can 
now easily do this in a storage-agnostic manner for both pre 2.2 and 
2.2. Nice, thanks for supplying that sample code Fred, after a couple 
hours looking through the Rails source I wasn't any closer to figuring 
it out for myself.

Ah, but I guess now I have your sample code to _read_ a session. Do you 
have any similar magic code to write it back out to the store? I guess I 
can probably figure it out for myself now that I know the magic way to 
fake a cgi session.

Jonathan
-- 
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: restful_authentication: 3 unit tests break!

2009-04-20 Thread Joshua Muheim

Fernando Perez wrote:
 I guess it has something to do with acts_as_state_machine?
 
 Yes. Don't you read the source code of your plugins before using them? 
 That's bold.

OK, I read some of the source code of the plugin. Sadly I'm no very 
experienced Ruby programmer, so I have a question.

Where does a new record get saved to the DB when calling register!?

 record = User.new({ :login = 'quire', :email = 'qu...@example.com', 
 :password = 'quire', :password_confirmation = 'quire' })
= #User id: nil, first_name: nil, last_name: nil, login: quire, 
email: qu...@example.com, remember_token: nil, crypted_password: nil, 
password_reset_code: nil, salt: nil, activation_code: nil, 
remember_token_expires_at: nil, activated_at: nil, deleted_at: nil, 
state: passive, created_at: nil, updated_at: nil
 record.new_record?
= true
 record.register!
= true
 record.new_record?
= false

I'm trying to get into this plugin, but it seems very tricky 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] acts_as_state_machine: bug?! obj.save doesn't work...

2009-04-20 Thread Joshua Muheim

Hi all

I'm trying to understand, what acts_as_state_machine really does (I use
it because restful_authentication uses it).

restful_authentication defines the following stuff:

  acts_as_state_machine :initial = :pending
  state :passive
  state :pending, :enter = :make_activation_code
  state :active,  :enter = :do_activate
  state :suspended
  state :deleted, :enter = :do_delete

  event :register do
transitions :from = :passive, :to = :pending, :guard = Proc.new
{|u| !(u.crypted_password.blank?  u.password.blank?) }
  end

  event :activate do
transitions :from = :pending, :to = :active
  end

  event :suspend do
transitions :from = [:passive, :pending, :active], :to =
:suspended
  end

  event :delete do
transitions :from = [:passive, :pending, :active, :suspended], :to
= :deleted
  end

  event :unsuspend do
transitions :from = :suspended, :to = :active,  :guard = Proc.new
{|u| !u.activated_at.blank? }
transitions :from = :suspended, :to = :pending, :guard = Proc.new
{|u| !u.activation_code.blank? }
transitions :from = :suspended, :to = :passive
  end

I played a bit with the console...

josh$ script/console
Loading development environment (Rails 2.1.0)
 record = User.new({ :login = 'quire', :email = 'qu...@example.com', 
 :password = 'quire', :password_confirmation = 'quire' })
= #User id: nil, first_name: nil, last_name: nil, login: quire,
email: qu...@example.com, remember_token: nil, crypted_password: nil,
password_reset_code: nil, salt: nil, activation_code: nil,
remember_token_expires_at: nil, activated_at: nil, deleted_at: nil,
state: passive, created_at: nil, updated_at: nil

Why is the state passive? Is the state of an unsaved object always
passive?

 record.save
= true
 record
= #User id: 4, first_name: nil, last_name: nil, login: quire, email:
qu...@example.com, remember_token: nil, crypted_password:
5670fb5c84b89d64ef405b315e4337304f88dc2b, password_reset_code: nil,
salt: a6ff544223bf2a7653651ea7f29888a195155c8d, activation_code:
43745d2e79d7aab4dfe2b4a3bd64d8ac577aeafe, remember_token_expires_at:
nil, activated_at: nil, deleted_at: nil, state: pending, created_at:
2009-04-20 20:19:15, updated_at: 2009-04-20 20:19:15

Looks good so far... But when looking at the database entry, the
activation_code actually is NULL! Let's prove this:

 record.reload
= #User id: 4, first_name: nil, last_name: nil, login: quire, email:
qu...@example.com, remember_token: nil, crypted_password:
5670fb5c84b89d64ef405b315e4337304f88dc2b, password_reset_code: nil,
salt: a6ff544223bf2a7653651ea7f29888a195155c8d, activation_code: nil,
remember_token_expires_at: nil, activated_at: nil, deleted_at: nil,
state: pending, created_at: 2009-04-20 20:19:15, updated_at:
2009-04-20 20:19:15

Tadaah! This is a serious bug, isn't it? The User object only works
correct when using register! instead of save:

josh$ script/console
Loading development environment (Rails 2.1.0)
 record = User.new({ :login = 'quire', :email = 'qu...@example.com', 
 :password = 'quire', :password_confirmation = 'quire' })
= #User id: nil, first_name: nil, last_name: nil, login: quire,
email: qu...@example.com, remember_token: nil, crypted_password: nil,
password_reset_code: nil, salt: nil, activation_code: nil,
remember_token_expires_at: nil, activated_at: nil, deleted_at: nil,
state: passive, created_at: nil, updated_at: nil
 record.register!
= true
 record.reload
= #User id: 5, first_name: nil, last_name: nil, login: quire, email:
qu...@example.com, remember_token: nil, crypted_password:
465f2d6572f47e9adec58022d938b134e570077b, password_reset_code: nil,
salt: 293aaa4b1a391f472803767c93c07bf7966e9141, activation_code:
1129116e89f989fee4dccb7eb38946c8e16af93a, remember_token_expires_at:
nil, activated_at: nil, deleted_at: nil, state: pending, created_at:
2009-04-20 20:22:03, updated_at: 2009-04-20 20:22:03

Can anyone approve this? In my oppinion, save should have exactly the
same effect like register!... but it definitely doesn't.

Thanks for your opinion.
Josh
-- 
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: Any plugin to send email asyncronously in the background

2009-04-20 Thread Harm

I used Spawn (http://blog.sidu.in/2008/06/spawn-reliable-background-
processing.html) _really_ easy to setup. Don't expect any great
control though.

On Apr 20, 9:13 pm, David Knorr perpl...@gmail.com wrote:
 On 20 Apr., 19:02, Ajaya Agrawalla rails-mailing-l...@andreas-s.net
 wrote:

  We would like to queue our emails and send them outside of the
  application using an external SMTP provider.  Any plugin out there which
  will do this for us? I would like to explore before we go all out 
  write our own.

  aj

 You can also take a look at this episode of 
 Railscasts:http://railscasts.com/episodes/129-custom-daemonMaking your own
 daemon to run in the background is surprisingly easy.

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



[Rails] Re: Any plugin to send email asyncronously in the background

2009-04-20 Thread Ajaya Agrawalla

Ajaya Agrawalla wrote:
 We would like to queue our emails and send them outside of the
 application using an external SMTP provider.  Any plugin out there which
 will do this for us? I would like to explore before we go all out 
 write our own.
 
 aj

thank you all for your suggestions. Instead of creating another queuing 
solution for email, i went back to default sendmail to send email  
configured sendmail to use an external authenticated SMTP server to 
relay the email.

http://www.phinesolutions.com/sendmail-gmail-smtp-relay-howto.html

Thanks

AJ
-- 
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: Running a specific migration

2009-04-20 Thread Duke Jones

script/console
 require 'db/migrate/20090418023701_add_product_messages.rb'
= [AddProductMessages]
 AddProductMessages.up
==  AddProductMessages: migrating 
=
-- create_table(:product_messages)
   - 0.7646s
   - 0 rows
-- create_table(:products_product_messages)
   - 0.0913s
   - 0 rows
==  AddProductMessages: migrated (0.8575s) 


voila!

Adam wrote:
 Hi all,
 
 I'm working on a large rails projects that has a lot of migration
 files (around 80). Through some development quirk, probably due to bad
 svn merging, my local database hasn't run migration 63. Is there a way
 to run this one file without having to roll back through all the later
 migrations, which would cause significant data loss?
 
 Many thanks,
 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: manual access to session data outside of request?

2009-04-20 Thread Jonathan Rochkind

Jonathan Rochkind wrote:

 Ah, but I guess now I have your sample code to _read_ a session. Do you 
 have any similar magic code to write it back out to the store? I guess I 
 can probably figure it out for myself now that I know the magic way to 
 fake a cgi session.


Ha, I've  made it work!  Now I just need to do it for rails 2.3 too, to 
have it both ways.

But here's the rails pre-2.3 version. Thanks Fred!

  Struct.new('FakeSession', :session_id)

  # Craziness to restore a session in Rails pre 2.2. Will most 
likely
  # need to be changed for Rails 2.2.

  fake_cgi_session = Struct::FakeSession.new('some session id')

  session_obj = 
ActionController::Base.session_store.new(fake_cgi_session)
  @session = session_obj.restore

  # Later, you've modified the hash and want to save it back to 
store?
  # just:

  session_obj.close




You want to save something, just modify that hash, and then call
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Nested params issue with Rack 1.0 / Unable to freeze Rails

2009-04-20 Thread Olaf S.

hi,

$ sudo rake rails:freeze:edge RELEASE=2.3.2.1

worked now, but the problem still persist. All my forms are broken.

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] optimistic locking with session store?

2009-04-20 Thread Jonathan Rochkind

Okay, continuing in my project of abusing Rails horribly.

It looks to me like even standard Rails sessions are subject to a race
condition if the same session is accessed concurrently. Request1 checks
out a session. Request 2 checks out a session, makes a change, and
writes it back to the store. Request 1, still finishing up, makes a
change, and writes the session back to the store... overwriting the
changes Request2 made.

So, if I'm using an ActiveRecord store... what happens if I just add a
lock_version column to the model?  But then I guess an exception will be
raised from the innards of ActiveController somewhere. And it would be
unclear how to recover from it. So that's not quite right.

Has anyone come up with an optimistic locking solution for Rails session
to get around this race condition issue?
-- 
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: Accessing Models via Views

2009-04-20 Thread Ar Chron

I tend to prefer code like:

@class.enrolled_students.each do |student|
   student.name
end

as Philip mentioned.

Enrolled students, if I understand your model(s) correctly, are just a 
specialized set of students. Not dropped_students, or 
withdrawn_students, or waitlisted_students, or students_on_hiatus, but 
those currently enrolled in the class.

The .each do |call it whatever| gives you the chance to map the 
'enrolled_students' back to their source, and pretty much anyone reading 
the code will make the leap (however small) that 'name' is an attribute 
or method of the 'student' class.
-- 
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: Accessing Models via Views

2009-04-20 Thread Phlip

Ar Chron wrote:

 I tend to prefer code like:
 
 @class.enrolled_students.each do |student|
student.name
 end
 
 as Phlip mentioned.

Tx - it reminded me to write up Contractive Delegation here:

   http://broadcast.oreilly.com/2009/04/contractive-delegation.html

I heard the term from an old Smalltalker, and it stuck...

-- 
   Phlip
   http://flea.sourceforge.net/resume.html


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



[Rails] Re: Opening a image located outside the public folder

2009-04-20 Thread Freddy Andersen

Do you have Apache as a frontend? then use alias and a directory
element to point apache away from the public directory.

Or use a symlink

On Apr 20, 4:10 pm, elioncho elion...@gmail.com wrote:
 Hello!

 Can anyone help me on how to open an image on the browser NOT located
 in the public folder. I am using the img tag, but the image doesn't
 opens because it's outside the public folder.

 Thanks,

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



[Rails] Re: :mem_cache_store and memcache-client

2009-04-20 Thread Rajat Garg

It seems to be working except that I am getting key too long error. If 
possible, can you tell me what I am missing?

I will really appreciate your help.


Processing ApplicationController#index (for 74.203.51.2 at 2009-04-20 
23:38:54) [GET]

ActionView::TemplateError (key too long 
rack:session:BAh7FzoQQWRkcmVzc0luZm8wOg9zZXNzaW9uX2lkIiVhNjQ2NDdhNDk2YmZjZjRhY2I2M2UyNTQ1ZTIzMDAwNToPY2FjaGVfZGF0YTA6F2Zvcm1fc3VibWl0X2Vycm9yczA6E2hvdGVsX2dlb19kYXRhex4iCzIwNjAwNXsHOg1sYXRpdHVkZSINNDcuNjIyNDQ6DmxvbmdpdHVkZSIPLTEyMi4zNTY3MiILMTg2MjQxewc7CiINNDcuNjI5NTQ7CyIPLTEyMi4zMjk5NCILMTE1MTIzewc7CiINNDcuNjEzODc7CyIPLTEyMi4zNDEzMSILMTI1NzE5ewc7CiINNDcuNjE1MzQ7CyIPLTEyMi4zNDE3NiILMjQzOTMyewc7CiINNDcuNjA0Nzc7CyIPLTEyMi4zMzYzMSILMjQyODI3ewc7CiINNDcuNjE4MDU7CyIPLTEyMi4zMzY0NSILMTY0MTIyewc7CiINNDcuNjEzMDk7CyIPLTEyMi4zMzc4OCILMTEyMTgyewc7CiINNDcuNjA4NTI7CyIPLTEyMi4zMjcyOCILMjc2ODE0ewc7CiINNDcuNDM1ODg7CyIPLTEyMi4yODc3MyILMTE1MDcyewc7CiINNDcuNjA4MzE7CyIPLTEyMi4zMzQ4MSILMjE2MTU1ewc7CiINNDcuNjExMjE7CyIPLTEyMi4zMjA4MSILMTQ4NTA1ewc7CiINNDcuNjEyMjM7CyIPLTEyMi4zMzg1MyILMTMyNjg0ewc7CiINNDcuNjA2ODE7CyIPLTEyMi4zMzM0OSILMjc2NTc1ewc7CiINNDcuNjEzMjg7CyIPLTEyMi4zMzMyOCILMTY0MTE2ewc7CiINNDcuNjEwMTc7CyIPLTEyMi4zMzM1NyILMTIzNDIzewc7CiINNDcuNDQwNjU7CyIPLTEyMi4yOTU4OSILMjYzNDAyewc7CiINNDcuNjAzNTM7CyIOLTEyMi4zMzIxIgsxMjI0Nzd7BzsKIg00Ny42MDQ2MTsLIg8tMTIyLjE5MDcxIgsxMTU3MDJ7BzsKIg00Ny42MTI3NTsLIg8tMTIyLjMzNDAyIgsyMDYwMDJ7BzsKIg00Ny42MjQ2ODsLIg8tMTIyLjM1NjczIgsyMDUyNzd7BzsKIg00Ny42NTk0OTsLIg8tMTIyLjMxNzgxIgsxMTM0MjZ7BzsKIg00Ny42MTM4MTsLIg8tMTIyLjMzNjg2IgsyMzU4OTF7BzsKIg00Ny41OTM2NzsLIg8tMTIyLjMzNDIyIgsyMDYwMDR7BzsKIg00Ny42MjMzMjsLIg8tMTIyLjM1NTQyIgsxMzIxMzh7BzsKIg00Ny42MDY4MjsLIg8tMTIyLjMzMzU4OhJsb2NhdGlvbl9pbmZvMDoSc2VhcmNoX2VuZ2luZTA6EWd1ZXN0X2NvdW50c3sHOg9udW1fYWR1bHRzIgYyOhFudW1fY2hpbGRyZW4iBjA6F2hvdGVsX2Jvb2tpbmdfaW5mbzA6EGZvcm1fcGFyYW1zMDoXZ3Vlc3RfY2xpY2tzX2NvdW50aRo6DXJvb21feG1sIgGGPFJvb21Hcm91cD48Um9vbT48bnVtYmVyT2ZBZHVsdHM+MjwvbnVtYmVyT2ZBZHVsdHM+CjxudW1iZXJPZkNoaWxkcmVuPjA8L251bWJlck9mQ2hpbGRyZW4+CjxjaGlsZEFnZXM+PC9jaGlsZEFnZXM+CjwvUm9vbT48L1Jvb21Hcm91cD46DWxhc3RQYWdlIgYvOhBsYXlvdXRfZmlsZSINYXV0b3Rvb2w6FFJlc2VydmF0aW9uSW5mbzA6GWhvdGVsX2RlcGFydHVyZV9kYXRlIg8wNy8yNy8yMDA5IgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsAOhdob3RlbF9hcnJpdmFsX2RhdGUiDzA3LzI1LzIwMDk=--44dde50c649bf5bb1e8e3688fd16e884024ee78d)
 
on line #40 of app/views/shared/_header.rhtml:
37:if(typeof(onloadJSDelegate)=='function'){
38:onloadJSDelegate();
39:}
40:%if(!flash[:notice].blank?)%
41:   alert('%=flash[:notice]%')
42:%end%
43: }



My config/environment.rb looks like this -
require 'memcache'
memcache_options = {
  :compression = true,
  :debug = false,
  :namespace = 'outlook',
  :readonly = false,
  :urlencode = false
}

memcache_servers = '[IP Address]:11211'

Rails::Initializer.run do |config|
  # Settings in config/environments/* take precedence over those 
specified here

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

  # Use the database for sessions instead of the file system
  # (create the session table with 'rake db:sessions:create')
  # config.action_controller.session_store = :active_record_store
  #config.action_controller.fragment_cache_store = :mem_cache_store, 
memcache_servers, memcache_options

  config.action_controller.session = {
 :session_key = '_tripoutlook_session_id',
 :secret = 'tripoutlook_a1b2c3d4e5g6h7i8'
  }
  config.action_controller.session_store = :mem_cache_store

end

cache_params = *([memcache_servers, memcache_options].flatten)
Cache = MemCache.new *cache_params
-- 
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: Using Paperclip::Processor and RMagick to sharpen my thumbnails

2009-04-20 Thread Matt W.

It seems that my processor isn't even being fired. There is no
evidence that it is even being called. I have it in the RAILS_ROOT/lib/
paperclip_processors directory and I've double checked the file names.
Does anyone have any idea what I'm doing wrong here?

Thanks!

M@

On Apr 17, 1:19 am, Shaun Keller rails-mailing-l...@andreas-s.net
wrote:
 Depends what exactly your error is, but I seem to recall RMagick having
 issues with TempFile's default naming convention. The default processor
 deals with that. Try subclassingPaperclip::Thumbnail instead?

 If not, could you provide more details on the nature of the actual
 error?
 --
 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] how to I see SQL trace when using (a) rails console (b) running rspec tests???

2009-04-20 Thread Greg Hauptmann
Hi,

I'd like to know how to monitor the SQL calls (from ActiveRecord) for both
the cases:
(a) using rails console [development mode], and
(b) running rspec tests [test mode]

How can I do this?  For item (a) I recollect previously I could just run up
a ./script/server and see this whilst using ./script/console however it
does not seem to be working currently for me.

Tks







-- 
Greg
http://blog.gregnet.org/

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



[Rails] Re: can anyone give a quick explaination...

2009-04-20 Thread Matt Jones

Not 100% sure what the difference is, but they're both WRONG. Adding
gem directories like that to the load path will only work for suitably
small values of work. Try the instructions here:

http://blog.juliankamil.com/article/26/installing-your-own-ruby-gems-in-a-shared-hosting-environment

to get this set up *correctly*. It might not seem like a big deal at
first, but the method recommended by your provider will break if gems
depend on other gems in your local repository.

--Matt Jones


On Apr 19, 3:29 pm, Gavin ga...@thinkersplayground.com wrote:
 Hey all!

 I've got an app on a shared host at the moment.

 They load ruby gems into a dir onto my space: home/myusername/ruby/
 gems/gems and recommend that you include this path by adding it to the
 load_path like so:

 $:.push(home/myusername/ruby/gems/gems)

 My question is - is this the same as adding

 config.load_paths += %w(home/myusername/ruby/gems/gems)

 to the environment.rb file?

 If so - cool!
 If not, can anyone explain what the difference is?

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



[Rails] Re: how to I see SQL trace when using (a) rails console (b) running rspec tests???

2009-04-20 Thread Philip Hallstrom


On Apr 20, 2009, at 5:53 PM, Greg Hauptmann wrote:

 Hi,

 I'd like to know how to monitor the SQL calls (from ActiveRecord)  
 for both
 the cases:
 (a) using rails console [development mode], and
 (b) running rspec tests [test mode]

 How can I do this?  For item (a) I recollect previously I could just  
 run up
 a ./script/server and see this whilst using ./script/console  
 however it
 does not seem to be working currently for me.

Not sure about (b), but for (a) put this in your ~/.irbrc

# Log to STDOUT if in Rails
if ENV.include?('RAILS_ENV')  !Object.const_defined? 
('RAILS_DEFAULT_LOGGER')
   require 'logger'
   RAILS_DEFAULT_LOGGER = Logger.new(STDOUT)
end

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



[Rails] Re: Errors when freezing rails

2009-04-20 Thread Matt Jones

Found one other mention that might be of interest:

http://www.ruby-forum.com/topic/115921

This is with a similar problem related to renaming session files.

Given that the above issue doesn't share any code with the
rails:freeze:gems task, I'm guessing this is some kind of extremely
obscure Ruby bug. And given that it doesn't occur when the commands
are executed in irb, it seems likely that it's some kind of filesystem
race condition...

Sj, could you try dropping a sleep(10) call in between the unpack and
move steps? If that makes the problem go away, that will be useful
information...

--Matt Jones

On Apr 19, 9:49 pm, Sj Tib rails-mailing-l...@andreas-s.net wrote:
 To eliminate any corruption I reinstalled ruby and rails (2.2.2) and
 created an empty project but the same error persists with rake
 rails:freeze:gems.

 Permission denied - activesupport-2.2.2 or activesupport

 I added some debug code to the mv function in fileUtils but I can't get
 any additional information.

 1. How can I debug rake tasks? Is there a way to set breakpoints in
 fileutils.rb when rake rails:freeze:gems runs so I can inspect the
 data there?

 2. How can I get information about what user is the command rake
 rails:freeze:gems running under? I am system admin on my box so I just
 don't understand the permission denied error I am seeing

 I also tried to go down the other path I had tried earlier to freeze
 rails with rake rails:freeze:edge TAG=rel_2-2-2. It looks like there
 the system can't find an unzip executable - I have Winzip on my box but
 not sure if that matters. I saw in another post
 (http://www.question-defense.com/2009/04/02/error-freezing-rails-usr-l...)
 that doing a yum install unzip on a linux box apparently solved this
 kind of problem. Is there an equivalent unzip install for XP box that
 might address this aspect of the problem?

 D:\TestRails2rake rails:freeze:edge TAG=rel_2-2-2 --trace
 (in D:/TestRails2)
 ** Invoke rails:freeze:edge (first_time)
 ** Execute rails:freeze:edge
 cd vendor
 Downloading Rails fromhttp://dev.rubyonrails.org/archives/rails_edge.zip
 Unpacking Rails
 rm -rf rails
 --- removed rails directory successfully
 c:/ruby/bin/rake.bat: No such file or directory - unzip rails.zip
 --- unzipped rails.zip
 rm -f rails.zip
 rm -f rails/Rakefile
 rm -f rails/cleanlogs.sh
 rm -f rails/pushgems.rb
 rm -f rails/release.rb
 touch rails/REVISION_7ce0778a1516110cf8015e59e2e8fac15032379c
 rake aborted!
 No such file or directory -
 rails/REVISION_7ce0778a1516110cf8015e59e2e8fac15032379c

 I don't really know what else to do to debug this problem. Could use
 some help/pointers  here.

 Thanks,
 -S
 --
 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] Generating Word Doc

2009-04-20 Thread Simon Macneall

Hi all,

Does anyone have any suggestions for generating a word doc from a linux rails 
application? We were using html and just naming it .doc, which works well until 
you need to embed images into the document. MHT looks promising but the only 
libraries aren't free (not a deal breaker, but free is better).

Thanks
Simon

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



[Rails] Re: can I do a named_scope for this scenario???

2009-04-20 Thread Greg Hauptmann
thanks, but this doesn't bring back Relationships, it brings back
Nodes...does a named_scope always bring back instances of the class it's
specified in it does it?

I really want a named_scope, or has_many version of the method
all_relations in my original email belowany more ideas anyone?

thanks


2009/4/15 Matt Jones al2o...@gmail.com


 You could try:

 named_scope :all_relations_for, lambda { |o| { :conditions =
 [node_id = :o_id OR dependant_node_id = :o_id, { :o_id =
 o.id }] } }

 That will let you do:

 Node.all_relations_for(Node.find(1)) etc.

 Not quite as snazzy as what you're looking for, but close...

 --Matt Jones

 On Apr 13, 6:26 pm, Greg Hauptmann greg.hauptmann.r...@gmail.com
 wrote:
  PS.  To further clarify my question note that:
 
  ---
  class Node  ActiveRecord::Base
has_many :relationships_as_child, :class_name = 'Relationship',
  :foreign_key = :dependant_node_id
has_many :relationships_as_parent, :class_name = 'Relationship',
  :foreign_key = :node_id
 
def all_relations
  Relationship.find(:all, :conditions = [node_id = ? OR
  dependant_node_id = ?, self.id, self.id])
end
  ---
 
  I can get the first two has_many working, but I can't work out how to
  effectively combine these two into one has_many.   I can create a 
  all_relations method however that does provide the full flexibility of a
 
  has_many or a named_scope version (which I'm after) as I can't then do
  further things like:
 
 Node.find(1).all_relations.find(1)   # fails
 
  So in other words I want the output of the all_relations function, but
 in
  the form of a has_many or a named_scope.
 
  Any help welcomed  :)
 
  2009/4/13 Greg Hauptmann greg.hauptmann.r...@gmail.com
 
 
 

 



-- 
Greg
http://blog.gregnet.org/

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



[Rails] Re: Generating Word Doc

2009-04-20 Thread Marnen Laibow-Koser

Simon Macneall wrote:
 Hi all,
 
 Does anyone have any suggestions for generating a word doc from a linux 
 rails application? 

Yes: don't do it.  Word documents have no place on the Web -- they don't 
reliably preserve formatting and they don't play nice with Web browsers. 
Generate a PDF file instead; prawn works well for this.

[...]
 Thanks
 Simon

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
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: Generating Word Doc

2009-04-20 Thread Simon Macneall

That's a fabulous answer. 
I wouldn't be asking if I could convince my customers that a PDF would do. They 
need to be able to edit the document after it is generated.

-1 for helpfulness


On Tue, 21 Apr 2009 11:38:01 +0800, Marnen Laibow-Koser 
rails-mailing-l...@andreas-s.net wrote:


 Simon Macneall wrote:
 Hi all,

 Does anyone have any suggestions for generating a word doc from a linux
 rails application?

 Yes: don't do it.  Word documents have no place on the Web -- they don't
 reliably preserve formatting and they don't play nice with Web browsers.
 Generate a PDF file instead; prawn works well for this.

 [...]
 Thanks
 Simon

 Best,
 --
 Marnen Laibow-Koser
 http://www.marnen.org
 mar...@marnen.org

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



[Rails] Re: Generating Word Doc

2009-04-20 Thread Andrew Timberlake

On Tue, Apr 21, 2009 at 5:58 AM, Simon Macneall macne...@gmail.com wrote:

 That's a fabulous answer.
 I wouldn't be asking if I could convince my customers that a PDF would do. 
 They need to be able to edit the document after it is generated.

 -1 for helpfulness


Totally off the wall here but .docx files are XML so why not generate
one in Word and then manipulate that from your app?

Another crazy idea is to use OpenOffice, I think they have a Java
interface that you might be able to hook into somehow.

I have not done either of these, just throwing out some ideas.

Andrew Timberlake
http://ramblingsonrails.com
http://www.linkedin.com/in/andrewtimberlake

I have never let my schooling interfere with my education - Mark Twain

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



  1   2   >