[Rails] Action Mailer 3.2.9 retruns duplicates in deliveries array

2012-12-05 Thread James Byrne
I am extracting a standalone batch application from a Rails 3.0.1
project.  This requires only ActiveRecord and ActionMailer.  In my
testing I set

   ActionMailer::Base.delivery_method = :test

This causes the mail to be delivered to the
ActionMailer::Base.deliveries array.  However, I am getting two of the
test email messages placed in the deliveries array instead of just one.
For example:

'[
#,
,
,
>,
,
,
,
>,

#,
,
,
>,
,
,
,
>
]'

I can forcibly fix this with a call to deliveries.unique but I would
rather find out what is actually happening.  Wherever this is occuring
it is between the call to the mail method in the mailer class and the
return from that class back to the calling script.  As I provide no
intervening code and since self.deliveries does not exist inside the
mailer class on return from the mail method I gather that this array and
method is being created and populated somewhere in the ActionMailer
stack outside of my pervue.

Does anyone have any idea why this is 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 https://groups.google.com/groups/opt_out.




[Rails] Re: Unable to install pg gem file on CENT OS

2012-12-05 Thread James Byrne
PavanKumar Chamarthi wrote in post #1087845:
> please help me in this... I am unable to install pg gem file
>
>
> [root@vdimc04 ~]# gem install pg -v '0.12.0'
> /usr/local/lib/ruby/1.9.1/yaml.rb:56:in `':
> It seems your ruby installation is missing psych (for YAML output).
> To eliminate this warning, please install libyaml and reinstall your
> ruby.
> Fetching: rake-compiler-0.8.1.gem (100%)
> Fetching: pg-0.12.0.gem (100%)
> Building native extensions.  This could take a while...
> ERROR:  Error installing pg:
> ERROR: Failed to build gem native extension.
>
> /usr/local/bin/ruby extconf.rb
> checking for pg_config... no
> No pg_config... trying anyway. If building fails, please try again with
>  --with-pg-config=/path/to/pg_config


> checking for libpq-fe.h... no
> Can't find the 'libpq-fe.h header
> *** extconf.rb failed ***

It is in your own interest to provide more detail respecting your 
installation when reporting a problem and asking for help.  For example, 
are you running CentOS-6 or 5?  What point release?  Are you using the 
stock PostgreSQl install, have you installed a different version from 
another respoitory,  or have you built PostgreSQl yourself?  In any case 
what version of Postgres?

Providing that you are running CentOS-6.x; and assuming that you are 
evidently not using the Postgres provided with that distribution; and 
guessing that you are likely using the pgdg-91-centos.repo; and also 
guessing that you are using either rvm or rbenv then you likely need to 
do something akin to the following

yum install postgresql91-devel libyaml
gem install pg --with-pg-config=/usr/pgsql-9.1/bin/pg_config

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 https://groups.google.com/groups/opt_out.




[Rails] Rails-3 Spurious NULL columns on INSERT

2011-03-30 Thread James Byrne
I have a model in whose migration I have defined a datetime column that
both has a default value and sets null to false.  As this is a
PostgreSQL database the default value is 'infinity', which may be the
source of the difficulty.

When I attempt to save this model ActiveRecord produces an SQL statement
that explicitly sets this column to NULL thus both defeating the purpose
of the default value and triggering the NOT NULL constraint on the DBMS.

How does one turn off or override this behaviour?  What I want to happen
is that model_instance.save will only specify columns that have values
set and will simply not include any column that does not have an
explicit value set.

I can see that for other attributes ActiveRecord is setting things to
the defaults provided in the migration. Is this the case? If not then
where is ActiveRecord getting this information?  And why bother?  The
purpose of a default value on a database column is to have the DBMS
provide for the absence of information at the DBMS level.  If I wish to
do that at the attribute level then I can do so in the model class
itself.

-- 
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] Handling a nested controller in a Rails3 route matcher

2011-03-29 Thread James Byrne
Rails-3.0.5

I am writing a custom matcher in routes.rb.  I wish to map a dynamic
segment to a nested params hash.  I cannot seem to determine how to pass
the value of the dynamic segment to a nested hash.

The code that I have is:

get "(/:path)/:pars",
  :action => :create,
  :controller => :customs_shipment_pars_checks,
  :ca_customs_manifest => { :ccdn  => :pars }

This passes params[:ca_customs_manifest][:ccdn] == :pars # a symbol
and params[:pars] == "somevalue"

changing the last line to:

  :ca_customs_manifest => { :ccdn  => %(pars) }

This passes params[:ca_customs_manifest][:ccdn] == pars # a string
and params[:pars] == "somevalue"

What I wish to do is to pass the dynamically assigned value of :pars to
the nested hash. How is this done?

-- 
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 Cucumber, Rails 3.0.5

2011-03-24 Thread James Byrne
Felipe Espinoza Castillo wrote in post #989076:
> I paste my stack overflow question please help, i'm really stuck
> with
> this.
>
> Hi Everyone,
>


in Gemfile set the version of cucumber-rails to 0.3.2

gem cucumber-rails, '=0.3.2'

run bundle update and roll back to cucumber 0.10.0.  There are a bunch 
of things rolled up into 0.10.2 that were separate in 0.10.0 and I have 
had problems with it myself.  If cucumber-0.10.0 was working for you 
then go back to that and let the new version of cucumber get itself 
sorted out before upgrading to it.

-- 
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] ActiveRecord and NULL in RoR-3

2011-03-08 Thread James Byrne
I have a situation where I am encountering a fragmented edi transaction.
What results is that I attempt to INSERT a row for which I am missing
some data. The columns affected all have sensible DEFAULT values but
most also have a NOT NULL constraint.

My problem is that notwithstanding I am not initializing those columns
in my program, ActiveRecord is nonetheless setting them to NULL for the
generated INSERT statement.  I can see that this is the case because I
initialize from a hash and the hash contents displayed immediately
before the failing INSERT does not contain the attribute that is causing
the exception.  Because that column is explicitly set to NULL in the
INSERT statement its DEFAULT value is not used and the NOT NULL
constraint is triggered.

Now, it is possible that I am misinterpreting what I am seeing.  My
question is: Does ActiveRecord, or some other part of the RoR DBMS
interface, actually explicitly set missing attributes to NULL on INSERT
rather than simply ignoring them?

-- 
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: Re: Trouble with titleize

2011-03-07 Thread James Byrne
Frederick Cheung wrote in post #986030:

>
> So the issue would seem to be that content_for is escaping the &
> (turning it into &), and then titleize, not knowing any better
> uppercases the & to &Amp. Character entities are case sensitive so
> this screws things up. Why not call titleize  in the content_for block?

Thank you Fred.  Yes, that works.  I did not think to do that because 
our practice is to apply styling methods at the moment of display.  On 
this page I can change that without difficulty but on others, as the 
text is sometimes used in multiple places on a page, I may not be so 
fortunate as in this example.

-- 
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: Trouble with titleize

2011-03-07 Thread James Byrne
Frederick Cheung wrote in post #986019:
> On 7 Mar 2011, at 17:42, James Byrne  wrote:
>
>> In one of my views I have this code:
>>
>>  <%=content_tag :h2, :header do-%>
>><%=yield(:page_title).html_safe?-%>
>><%=yield(:page_title).titleize-%>
>>  <%- end -%>
>>
>
> What exactly does yield(:page_title) return before you titleize it?
>
> Fred

  <%-content_for :page_title,
 "a boy & his dog"
  -%>



  <%=content_tag :h2, :header do-%>
<%=yield(:page_title)-%>
  <%- end -%>

displays:

a boy & his dog

-- 
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] Trouble with titleize

2011-03-07 Thread James Byrne
In one of my views I have this code:

  <%=content_tag :h2, :header do-%>
<%=yield(:page_title).html_safe?-%>
<%=yield(:page_title).titleize-%>
  <%- end -%>

Which displays:

true A Boy &Amp; His Dog

However this code:


  <%=content_tag :h2, :header do-%>
<%=yield(:page_title).html_safe?-%>
<%=yield(:page_title).capitalize-%>
  <%- end -%>

displays:

true A boy & his dog

Is this behaviour of titleize intentional?  I want to titleize 'a dog &
his boy' and preserve the & character in the final display.

-- 
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: Howto enter nonbreaking spaces in I18n translarion file

2011-03-04 Thread James Byrne
Solved it:

UTF-8 nonbreaking space = "\xC2\xA0"

so

date_time_key: "\xC2\xA0mm\xC2\xA0dd hh:mm\xC2\xA0+-hmm"

-- 
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] Howto enter nonbreaking spaces in I18n translarion file

2011-03-04 Thread James Byrne
I have the following in my en.yml file

date_time_key: " mm dd hh:mm utc +-hmm"

I would like to have the spaces in ' mm dd' and 'utc +-hmm' replaced
with a non-breaking character unicode .  How is this done, or is
it even possible in Ruby-1.8.7?

The wiki pages and discussions that I have managed to find do not seem
to address this sort of thing directly.

-- 
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] Forcing an insert instead of an update

2011-02-22 Thread James Byrne
I have a has_many association that I wish to append records to.
However, what happens instead is that the first row inserted gets
updated in place thereafter.  The way I am creating this append row is
this:

current_log_entry = current_entry.ca_customs_edi_log_entries.build

This is then saved when the related row in the parent table is saved.
How do I force an insert rather than an update for rows after the first?

-- 
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: Re: Trouble using associations with to_param

2011-02-22 Thread James Byrne
Colin Law wrote in post #983199:

>
> Perhaps you need :foreign_key here also.
>
> Colin

I will try this if I ever go back to that idiom.  Based on your 
suggestion I discover that this parameter is required only for the 
belongs_to method. The API documentation does not give an explicit 
example of this usage early up in the introduction where I think it 
might be very helpful.

-- 
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: Trouble using associations with to_param

2011-02-22 Thread James Byrne
James Byrne wrote in post #983156:
> When I do this I obtain nil:
>
> current_shipment = current_entry.shipment
>
.  .  .
>
> Clearly I am missing something or other in the association method call
> but I cannot seem to find what that something is.
>
> Does anyone here see what I am doing wrong?

What I did was to change the association call named #shipment to:

current_shipment = current_entry.ca_customs_shipment

and things worked.  So, now my question is: what is wrong with this 
code?

# #shipment returns nil always
  belongs_to  :shipment, :class_name => 'CaCustomsShipment'

# returns ca_customs_shipment
  belongs_to  :ca_customs_shipment

-- 
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] Trouble using associations with to_param

2011-02-22 Thread James Byrne
When I do this I obtain nil:

current_shipment = current_entry.shipment

The models look like this:

class CaCustomsShipment < ActiveRecord::Base

  has_one   :ca_customs_entry
  has_one   :entry,
:class_name => 'CaCustomsEntry' #short form

  def to_param
shipment_identifier
  end


class CaCustomsEntry < ActiveRecord::Base

  belongs_to  :ca_customs_shipment
  belongs_to  :shipment, :class_name => 'CaCustomsShipment'

  def to_param
cctn
  end


If I fetch the rows individually via .first then I see this:

  --- !ruby/object:CaCustomsEntry
  attributes:
.  .  .
created_at: 2011-02-22 16:40:49.085782
.  .  .
ca_customs_shipment_id: "111"

and

 --- !ruby/object:CaCustomsShipment
  attributes:
.  .  .
lock_version: "0"
id: "111"
.  .  .

However, If I do this:

puts( CaCustomsShipment.first.entry.to_yaml )
puts( CaCustomsEntry.first.shipment.to_yaml )

The first puts displays the entry I expect but the second returns nil. I
also discovered that this fails:

CaCustomsShipment( CaCustomsEntry.first.ca_customs_shipment_id )

but this succeeds

CaCustomsShipment.find_by_id(
CaCustomsEntry.first.ca_customs_shipment_id )

This gave rise to the thought that perhaps I was handling the to_param
methods incorrectly.  I tried removing the to_param definitions from the
respective models but the program behaviour does not appear to change.

Clearly I am missing something or other in the association method call
but I cannot seem to find what that something is.

Does anyone here see what I am doing wrong?

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

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



[Rails] Re: Having a problem initializing an associated table

2011-02-07 Thread James Byrne
Colin Law wrote in post #980132:
> On 7 February 2011 21:06, James Byrne  wrote:
>> puts( current_log_entry.class )
>> puts( hash[:current_batch][:tx_batch_mtime] )
>>
>>   current_log_entry.tx_batch_mtime = \  # linebreak for clarity
>
> The \ must be the last char on the line, though I would have expected
> this to generate a compile error.
>

The line break and comment exist only in the forum message because of 
the way the forum wrapped the unbroken line found in the code.

I discovered the problem.  mtime is a datetime attribute in the model 
and an integer in the hash.  So I required 
Time.at(hash[:current_batch][:tx_batch_mtime]) for the assignment to 
work.

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

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



[Rails] Having a problem initializing an associated table

2011-02-07 Thread James Byrne
Q.  What am I doing wrong such that tx_batch_mtime is not receiving the
value I believe that I am assigning?  At this point current_entry has
not itself been saved.

I have this code:

puts( "***  ***" *3 )

  current_log_entry = current_entry.edi_log_entries.build

puts( current_log_entry.class )
puts( hash[:current_batch][:tx_batch_mtime] )

  current_log_entry.tx_batch_mtime = \   # linebreak for clarity
hash[:current_batch][:tx_batch_mtime]

puts( current_log_entry.to_yaml )
puts( current_entry.cctn )
puts()

Which produces this output:

  ***  **  **  ***
  CaCustomsEdiLogEntry
  1276181402
  --- !ruby/object:CaCustomsEdiLogEntry
  attributes:
tx_batch_number:
created_at:
changed_by: " "
tx_message_function:
tx_record_type:
tx_batch_date:
lock_version: 0
tx_batch_account:
created_by: " "
accessed_at:
tx_batch_mtime:
tx_message_data:
changed_at:
accessed_from: " "
ca_customs_entry_id:
accessed_by: " "
  attributes_cache: {}

  changed_attributes: {}

  destroyed: false
  marked_for_destruction: false
  persisted: false
  previously_changed: {}

  readonly: false
  13466600016294

  1276181402
  20100610
  13466
  009

As you can see, current_edi_log.tx_batch_mtime is nil whereas I expect
it to be 1276181402.  Why?

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

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



[Rails] Re: ActiveRecord Select

2011-01-20 Thread James Byrne
Frederick Cheung wrote in post #975887:

>
> foo(&:bar) is basically short hand for foo {|f| f.bar}. You'll
> probably get more google hits by searching for Sym to_proc
>
> Fred

Thanks.  I indeed did have more success with 'Sym to proc'.  Of course 
the bar was set rather low given I found nothing the other way.

BTW I realized my original desire with a little ( actually a great deal 
of ) help from the PostgreSQL list.  The following works like a champ, 
but only for PostgreSQL as far as I know.

 > cset = Client.select("DISTINCT ON(client_category) *")
 => [ .  .  .
 >
 > cset.size
 => 6
 > cset[0]
 => #, dollar_value_currency_code: 
"CAD", expected_at: "2010-07-19 04:00:00", expected_to: "133", 
client_category: "0492", office_code_for_unlading: "", 
service_priority: " ", service_option_identifier: "00257", .  .  ., 
lock_version: 0>


The DISTINCT ON  extension might be of some interest to those working in 
PostgreSQl.

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

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



[Rails] Re: ActiveRecord Select

2011-01-18 Thread James Byrne
Michael Pavling wrote in post #975879:

>
> Comparing your solution to Tim's suggestion, I infer that you don't
> have "client_category" as an association? (ie: client belongs_to
> :category).

No, we do not have any association by that name. The data originates off 
site and we do not know what client_categories are even possible or what 
the codes mean.

> You could use the "group_by" method for collections, and select the
> first off each group - that saves you doing a query per client, at the
> cost of doing one large query and a load of Ruby iteration.
>
>   Client.all.group_by(&:client_category).map(&:first)

Could you explain the '&:' idiom to me?  I cannot seem to find any 
examples of it by googling.

>
> At the end of the day, you're in the realms of doing some fudging to
> get the data out you're after (as you've discovered), as you're not
> doing something that's a natural fit for the DB or ORM. Sorry if
> that's not massively helpful... just letting you know we feel your
> pain.

Thanks. Misery shared is misery lessened.

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

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



[Rails] Re: ActiveRecord Session Store problem with AuthLogic

2011-01-18 Thread James Byrne
Robert Walker wrote in post #975877:

>
> I don't use AuthLogic myself,

I expect to be in the same situation shortly.  I am now looking at 
Devise.

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

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



[Rails] Re: ActiveRecord Session Store problem with AuthLogic

2011-01-18 Thread James Byrne
How does AR Session Store handle the case where there is no session?

In other words, some of the web pages that are produced by our 
application are meant to be publicly viewed without logging in.  This 
seems to be the problem.  It on the welcome page that the show action is 
causing the DBMS to throw a null entry error.

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

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



[Rails] Re: ActiveRecord Session Store problem with AuthLogic

2011-01-18 Thread James Byrne
Robert Walker wrote in post #975828:

>
> No AuthLogic or anything else involved. I'd check your session store
> configuration against what I showed here. Good luck.

I have checked both the session store and the session migration.  I can 
see no problems there. The way we migrated from 2.3 to 3.0 was to first 
create a new Rails 3 application and then copy in the .git directory 
from the original.  We then reconciled all of the diffs. As far as I can 
determine, all of the cruft was left behind.

I have no doubt that AR Session Store works in a new Rails 3 application 
without AuthLogic.  But that is irrelevant.  The entire issue revolves 
around getting AuthLogic to work with AR Session Store.

I simply cannot get AR Session Store to work with our AuthLogic setup. I 
cannot discover why it works in Rails 2.3.8 and not in Rails 3.0.3.

Presumably, AuthLogic sets session.session_id to some value somewhere. 
However, AL uses an attribute called session_id to keep track of 
multiple concurrent sessions for the same user and I wonder if there is 
some problem that practice introduced in Rails3.

I have asked about this on the AL list when it first cropped up and I 
never received any reply.  Does anyone here happen to use AL and AR SS 
together on a Rails 3 project?

-- 
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: Re: Re: ActiveRecord Select

2011-01-18 Thread James Byrne
Tim Shaffer wrote in post #975786:
>
>
> Here is an example of code that would fit your needs:
>
> records = []
> Category.all.each do |category|
>   records << category.clients.first
> end

Yes, that is what I ended up doing, more or less. What I did was this:

> cset = []
> Client.select("DISTINCT(client_category)").each do |c|
>  cset << Client.find_by_client_category(c.client_category)
> end

However, since I was in the console when I ran into this situation I was 
hoping that there existed a more direct way of accomplishing it ( in 
other words on a single line ) and that I was simply ignorant of the 
method.  Thus my question.

Thank all of you for your comments and help.

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

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



[Rails] Re: Re: Re: ActiveRecord Select

2011-01-18 Thread James Byrne
Robert Walker wrote in post #975774:

>
> This requirement in itself raises questions about your design in my
> mind, but it's your project and you're closer to the problem domain.

This is not part of any design.  I need a small sample of representative 
test data from a live data set such that each row belongs to a different 
category and all active categories are represented. Period.

-- 
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: Re: Re: ActiveRecord Select

2011-01-18 Thread James Byrne
Colin Law wrote in post #975760:

> I am interested to know why, when you do not care what the rest of the
> row contains.
>

I have answered that question. I just want to quickly obtain one
representative row from each category.  I can get the same result by
iterating over an array of possible values and doing a
find_by_category(x).first on each.  I would prefer a less cumbersome
approach.

Do you know how to accomplish what I desire?  If so then I would
appreciate it if you would tell me.

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

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



[Rails] Re: Re: ActiveRecord Select

2011-01-18 Thread James Byrne
Colin Law wrote in post #975727:
> On 18 January 2011 15:14, James Byrne  wrote:
>>>
>>> If you are selecting distinct client_category, and want the full row,
>>> which
>>> of the two "Cat1" rows should it return?
>>
>> What I want to accomplish is to obtain one example of each value and the
>> entire row that contains it. How does one do that? I do not care which
>> row is returned but I only want one row for each distinct value.
>
> Why?  If you do not care which row is returned then presumably you do
> not care what is in the rest of the row so why do you need it?
>
> Colin

Because I want one representative row for each category.

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

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



[Rails] Re: ActiveRecord Select

2011-01-18 Thread James Byrne
Tim Shaffer wrote in post #975719:
> Queries don't really work that way. You can't really select the full
> record when using distinct client_category.
>
> Lets say you have the following rows:
>
> client_category, client_name
> Cat1, Foo
> Cat1, Bar
> Cat2, Other
>
> If you are selecting distinct client_category, and want the full row,
> which
> of the two "Cat1" rows should it return?

What I want to accomplish is to obtain one example of each value and the 
entire row that contains it.  How does one do that?  I do not care which 
row is returned but I only want one row for each distinct value.

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

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



[Rails] ActiveRecord Select

2011-01-18 Thread James Byrne
If I do this:

x = Client.select("DISTINCT(client_category)")

Then I get an array of relations.  Instead, what I need is the entire
row (model instance attributes) for each of the returned relations.
What is the syntax to obtain the complete records?

I cannot find a discussion of the select method in the current AR API
(http://api.rubyonrails.org/classes/ActiveRecord/Base.html) and so I am
having some difficulty in turning this into something I can use.

-- 
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] ActiveRecord Session Store problem with AuthLogic

2011-01-18 Thread James Byrne
I have asked about this problem elsewhere and have as yet not had any
answer.

I cannot determine what is wrong with our Session store
configuration.  In Rails2 we used AR store with AuthLogic without
problem.  When we switched to Rails3 we ended up using cookie store
because we could not get AR store to work.  Now I would like to
discover why we are having this problem and fix it.

What is NOT happening is that the session_id in the sessions model
is not being initialized.  Therefore we see this DBMS error:

  PGError: ERROR:  null value in column "session_id" violates
not-null constraint
  : INSERT INTO "sessions" ("session_id", "updated_at",
"created_at", "lock_version", "data") VALUES (NULL, .  .  .

We never explicitly set session_id in Rails2 and I cannot figure out
how to do so so now.  Does anyone know hat one must do to initialize
session_id from inside AuthLogic?

-- 
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: Forcing PUT vs. POST in form

2011-01-06 Thread James Byrne
Interestingly, w3.org indicates that there are only two valid HTTP verbs 
for the form and the submit elements.  Those are GET and POST.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Forceing PUST vs. POST in form

2011-01-06 Thread James Byrne
Marnen Laibow-Koser wrote in post #972947:

> No!  If you need to make the form submission GET, then something is
> *badly wrong*.  Rails' resource mapping should make the PUT form work by
> default.  If that isn't working, find out why.  Perhaps we should take a
> look at your routes.
>

I believe that I know the source of the problem.  I have deliberately 
created a merged edit/new form and forced the controller to map 
different methods to specific templates.  I do not intend for this to 
remain.  But I am interested in seeing what behaviour results.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Forceing PUST vs. POST in form

2011-01-06 Thread James Byrne
Marnen Laibow-Koser wrote in post #972943:

>
> You probably don't want the form submission to be GET.
>
You are probably right.  But for now I am simply exploring how things 
work for a nested resource.  I will rewire the controller when I figure 
how what I want each bit to do and how I want it to look.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Forceing PUST vs. POST in form

2011-01-06 Thread James Byrne
Marnen Laibow-Koser wrote in post #972933:

>
> But you came from it as GET, not PUT.  Routes include method, not just
> URL.
>

I knew that. Nonetheless that is the bit I had confused.  I was trying 
to override the form method for the right reason but I fixed upon the 
wrong method, PUT, instead of GET.

Thank you for the help.

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

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



[Rails] Re: Forceing PUST vs. POST in form

2011-01-06 Thread James Byrne
Marnen Laibow-Koser wrote in post #972921:
> James Byrne wrote in post #972918:

>>
>> Then does that mean one must always provide a route for the new method,
>> even if it makes no sense to do so within a given context?
>
> I don't understand your question.
>

I get this error when I submit the form.

no route exists for "/users/1/roles"

However, I get to the form via "/users/1/roles/new" called from 
"/users/1/role", which is where I want to return to after the update 
completes.  At the moment I am perplexed by this, to me, mysterious 
behaviour and error message.

In other words, I can start by entering 
http://localhost:3000/users/1/roles

That URL displays all the roles associated with User.find(1)

>From that page I follow a link to 
http://localhost:3000/users/1/roles/new
which displays the input form.  When I complete and submit the form I 
get this error:

No route matches "/users/1/roles"

which is the very URL I have just come from.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Forceing PUST vs. POST in form

2011-01-06 Thread James Byrne
Marnen Laibow-Koser wrote in post #972876:
> James Byrne wrote in post #972875:
>> I am experimenting with a combined form.  I wish to force the HTTP verb
>> for this form to PUT.  However, it always uses POST when submitted and I
>> cannot determine why.
>
> Because that's the way Rails works.  Many browsers don't support PUT
> forms, so Rails leaves the method as POST and adds a hidden field to
> fake what the method "really" is.  Rails does the processing of that
> hidden field transparently, so that a POST with method "_put" will
> appear to the framework exactly like a real PUT.
>

Then does that mean one must always provide a route for the new method, 
even if it makes no sense to do so within a given context?

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Forceing PUST vs. POST in form

2011-01-06 Thread James Byrne
I am experimenting with a combined form.  I wish to force the HTTP verb
for this form to PUT.  However, it always uses POST when submitted and I
cannot determine why.

The view template code is:

  <%=form_for( @user,
  :html => {
:class => :edit_user_role,
:id => :edit_user_role_form,
:method => :put },
  :url => user_roles_url( @user )

) do |f|-%>

The resulting html is:

http://www.example.com/users/330/roles";
  class="edit_user_role"
  id="edit_user_role_form" method="post">
  


  

This confuses me.  The form method is not being set by the html
attribute but a hidden field is being created instead.  Since Rails
considers only the HTTP verb for routing this simply will not work as I
expect.

What is the problem with my approach?  How does one set the form method?

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Cucumber + Capybara - web sessions

2010-12-15 Thread James Byrne
Leandro wrote in post #968636:
> Given /I am not logged in/ do
> session.destroy
> end
>
> It doesn't work!

When you say "It doesn't work!" what error are you getting?  Is session 
defined?  If not then do you have sessions turned off in the 
ApplicationController?  Have you established a session to start with?

Take a look at this for further help:

http://rails.nuvvo.com/lesson/6372-action-controller-session

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Cucumber + Capybara - web sessions

2010-12-14 Thread James Byrne
Have you tried:

session.delete

or perhaps:

session.destroy

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] render behaviour in controller action

2010-12-14 Thread James Byrne
I have an odd situation which involves an unrestricted, publicly
accessible, part of our application that is reached via an entirely
different domain name from that of the main application.  This portion
has only two methods, new (with create of course) and show.

The requirements are that only the root url and the show url are valid
for this domain.  Anything else returns to the new action.  However, if
the show url is given for the initial request, in other words the new
action has not previously been invoked for this session, then that too
must go to the new action.  Otherwise, it displays the results of the
generated request on the show page.

What I tried to do was to check for the presence of a model in the show
action:

def show
  return new unless @model
  .  .  . blah blah
end

This worked, up to a point.  If the current request did not have a model
instance then even with the show url provided on the address the new
method was instead invoked.  However, what I discovered is that in this
event the show template is rendered from within the new method
nonetheless.  I tried explicitly setting render :action => :new inside
the new method, and this worked for the cases redirected from show.
However, this causes a multiple render error in other cases.

I then tried rendering the :new action template inside show if the model
was nil.  That caused a nil attribute error in the new template since
the model skeleton was not initialized by the new method.

My first question is: where is the show template render being set?

The second is:  why does not the controller switch to the new method
change the render template to the default for that action?

The third is: What is the correct way to accomplish what I am doing?
Anything that gets this involved usually indicates to me that I have
fundamentally misunderstood something fairly basic.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Rails 3. deployment with Bundler

2010-12-09 Thread James Byrne
flyerhzm wrote in post #967353:
> Here is a post you may interest
> http://rails-bestpractices.com/posts/51-dry-bundler-in-capistrano

Very helpful! Thank you.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Rails 3. deployment with Bundler

2010-12-08 Thread James Byrne
I have a 32 bit server that I wish to deploy an application to.  I have
the deploy branch checked out on an i86_64 bit machine.  What is the
proper way to deploy the application and its gems from the i86_64
machine?

Do I configure a deployment specific Gemfile, send only that, and then
run bundle package as a Capistrano task?  What is the preferred way?

bundle install --deployment creates a vendor/bundle with architecture
specific gem libraries.  Some of these then have the wrong ELF when
deployed to a different architecture, thus the question.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Rails-3.0.3 gives Completed 406 Not Acceptable

2010-11-22 Thread James Byrne
Updating to Rails-3.0.3 resulted in 14 tests failing.  Investigating one
of them I discover that this message "Completed 406 Not Acceptable in
223ms" is being returned instead of the expected page.  This error
indicates tha the format of the request cannot be satisfied.  Usually a
format specification is html or json or pdf.  Imagine my surprise then
when I see in the html generated from the view template:


Roles


instead of:


Roles


The question is: Why is Rails 3.0.3 asking for a format of .1 instead of
requesting a user with id == 1?

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send 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 case statement and mb_chars in Ruby-1.9.2

2010-11-10 Thread James Byrne
RoR-3.0.1

I have this case statement:

  case n.hll_normalize
when "common name"
  @my_correspondent.correspondent_common_name = s
when "legal name"
  .  .  .
else
  raise ArgumentError, "#{n} attribute is not provided for."
  end

hll_normalize is defined as:

  def hll_normalise
strip.squeeze(" ").mb_chars.downcase
  end

I pass this case statement this value for n: "common name"

When run with Ruby-1.8.7p302 this works.  The exact same code run with
Ruby-1.9.2p0 yields:

common name attribute is not provided for. (ArgumentError)

When I enter rails console then I see this:

$ rails c
Loading development environment (Rails 3.0.1)
ruby-1.9.2-p0 > x = "common name"
 => "common name"
ruby-1.9.2-p0 > x.mb_chars
 => common name
ruby-1.9.2-p0 > x.mb_chars.downcase
 => common name
ruby-1.9.2-p0 > "common name" == x.mb_chars.downcase
 => true
ruby-1.9.2-p0 > "common name" == x.strip.squeeze(" ").mb_chars.downcase
 => true
ruby-1.9.2-p0 > case x.strip.squeeze(" ").mb_chars.downcase
ruby-1.9.2-p0 ?>  when "uncommon" then puts "nothing"
ruby-1.9.2-p0 ?>  when "common name" then puts x
ruby-1.9.2-p0 ?>  end
 => nil
ruby-1.9.2-p0 >

So, what is the case statement sensitive wrt mb_chars that changes the
result of "common name" == x.strip.squeeze(" ").mb_chars.downcase when
used as an argument?  Is there a nil coming back from somewhere in the
case statement argument evaluation when mb_chars is involved?

This is definitely related to mb_chars because this works:

ruby-1.9.2-p0 > case x.strip.squeeze(" ").downcase
ruby-1.9.2-p0 ?>  when "uncommon" then puts "nothing"
ruby-1.9.2-p0 ?>  when "common name" then puts x
ruby-1.9.2-p0 ?>  end
common name
 => nil
ruby-1.9.2-p0 >

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: [Cucumber]Which example fails??

2010-11-10 Thread James Byrne
Jeroen van Ingen wrote in post #960472:

>
> I know that it fails on this line 'And I should see "Welcome."' for 2
> of the 5 tests. But Cucumber doesn't give which example fails.
> Cucumber only gives the failing line of the Scenario Outline and not
> from the Examples.
> Does anyone know how to get for which example it fails?

Have you tried puts( user data ) statement in the step definition 
immediately before the failing test?

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Trying to work through update of Ruby and Install of Rails

2010-10-29 Thread James Byrne
Stefan Hinck wrote in post #958118:
> Hello all
>
> Newb alert...
>
> I am trying to install Rails and also update ruby.
>
> I am running OSX and found that my Ruby version is 1.8.7
>

>
> P.S. I was just going to use TextMate as my editor, though maybe I
> should be using this xCode?

xCode is the Software Development Kit for OSX.  It provides the 
compliers and necessary headers to successfully build software on a Mac. 
The package is about 800Mb last time I looked.  An older version can be 
found on either the system or application disk that ships with your Mac. 
I cannot say whether or not xCode contains any editors but it certainly 
is not one itself.  Regardless, if you are going to develop in Ruby on a 
Mac using native mode gems then the xCode package must be installed.

Once xCode is installed I strongly recommend that you install RVM 
(http://rvm.beginrescueend.com/) before doing anything else.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Is there a Rails3 way to "scope" views?

2010-10-28 Thread James Byrne
Daniel Guettler wrote in post #957936:
> Not sure if it's possible in your architecture, but we are working a
> lot with namespaces.
> E.g. you could have a Customs::ShipmentParsChecksController and a
> Customs::SomeOtherController etc. this would group your controllers,
> models and views into related sections.
> Your views then would look like:
> app
>  - views
>   - customs
>+ shipment_pars_checks
>+ some_other
>
> Best, Daniel

Thanks.  I will look into this.  I have not worked with namespaces so I 
never thought of that approach.

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

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



[Rails] Re: Is there a Rails3 way to "scope" views?

2010-10-28 Thread James Byrne
Marnen Laibow-Koser wrote in post #957913:

> To me too -- if we're talking *files*.  But again: that should never
> happen.  Let's see your views and controllers.  I suspect you are trying
> to cram too much into a single controller, and ending up with lots of
> actions and views as a result.
>

I mis-wrote.  As you picked up I really meant view directories. But, why
should it never happen for view directories?

I am writing an application that handles international freight bookings,
movements and customs formalities including edi cusdec transmissions.
That is never ever going to fit into a handful of controllers.  In fact,
but for foreign exchange, most controllers possess only the basic index,
show, new, create, and destroy actions.  Many do not have all of these.

A sample controller, one of the more complex ones, is given below:

class CustomsShipmentParsChecksController < ApplicationController

  skip_before_filter  :authenticated
  skip_before_filter  :authorised

  # POST /collection
  # POST /collection.xml
  def create

respond_to do |format|
  if @manifest = CaCustomsManifest.find_by_ccdn(
params[:ca_customs_manifest][:ccdn].strip)

@shipment = @manifest.ca_customs_shipment
@entry = @shipment.ca_customs_entry

if
@manifest.ca_customs_shipment.ca_customs_entry.is_across_accepted
  flash[:info] = accepted_message
  # render simply uses the template specified by the :action key
  # without calling the method.
  format.html { render  :action => "show" }
  format.xml  { render  :xml => @shipment,
:status => :accepted,
:location =>
:customs_shipment_pars_check }
else
  flash[:notice] = not_accepted_message
  format.html { render  :action => "show", :id => @shipment.id }
  format.xml  { render  :xml => @manifest,
:status => :found,
:location =>
:customs_shipment_pars_check }
end
  else
new # build a dummy record complex to allow display of messages
manifest.ccdn = params[:ca_customs_manifest][:ccdn].strip
flash[:notice] = not_found_message
flash[:warn] = contact_message
format.html { render  :action => "new" }
format.xml  { render  :xml => @manifest.errors,
  :status => :not_found }
  end
end
  end

  # DELETE /collection/:id
  # DELETE /collection/:id.xml
  def delete
show
  end

  # Do not raise pointless not found errors
  # GET /collection/:id/edit
  def edit
show
  end

  # GET /collection/new
  # GET /collection/new.xml
  def new
@shipment = CaCustomsShipment.new
@entry = @shipment.build_ca_customs_entry
@manifest = @shipment.ca_customs_manifests.build
  end

  # GET /collection
  # GET /collection.xml
  def index
new
  end

  # GET /collection/:id
  # GET /collection/:id.xml
  def show
get_shipment
  end

private
 ...

end

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

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



[Rails] Re: Is there a Rails3 way to "scope" views?

2010-10-28 Thread James Byrne
To me, having several hundred files in a single directory is cluttered. 
Others have different thresholds of tolerance.  Mine is low.

In any case, once given the hint above I managed to locate some 
information on ActonController.config.view_paths.  Not enough to 
actually try anything just yet, but the leads are promising.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Is there a Rails3 way to "scope" views?

2010-10-28 Thread James Byrne
I am finding my views directory a bit cluttered and I would like to move
some related views into their own subdirectory under app/views.  Is
there a Rails way to specify that app/views/** should be searched in
addition to app/views?

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Help with routes

2010-10-27 Thread James Byrne
Switching our routes file from Rails2 to Rails3 DSl uncovered an odd
situation, of my own making, but I am having some difficultly imagining
how to fix it.

Basically I have a commonplace: user -> user_role (clearance) <- role
type arrangement where:

User
  has_many  :roles, :through => :clearances
  has_many  :clearances

Clearance
  belongs_to :role
  belongs_to :user

and

Role
  has_many  :users, :through => :clearances
  has_many  :clearances

What I am trying to do is to link through new_user_role_path(@user).
But I get the following error when I try:

ActionController::RoutingError: No route matches
  {:action=>"new", :controller=>"user_roles"}

The thing is that when I run rake routes I see this:

 new_user_role GET/users/:user_id/role/new(.:format)
  {:controller=>"user_roles", :action=>"new"}

So, I am somewhat nonplussed as to what is going on. I probably am
misunderstanding something basic but from my point of view it seems
that the route that is shown as missing is actually there.  Is there
something else I am overlooking?

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: bundler installs gems in project rspec directory?

2010-10-26 Thread James Byrne
I forgot to mention the solution:

in .bundle/config

BUNDLE_DISABLE_SHARED_GEMS: "0"

However, I seem to observe that running bundle install resets this value 
to 1.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: bundler installs gems in project rspec directory?

2010-10-26 Thread James Byrne
I found it.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] bundler installs gems in project rspec directory?

2010-10-26 Thread James Byrne
Having just converted my project to rails3 I now note that bundler
installs gems into a directory called rspec in the project root.  Since
this defeats entirely the purpose of having central gem libraries I need
to know how to turn this 'feature' off.

Out of pathological curiosity I do not mind finding out how this
happened to me and why such a thing is even possible, but I can
certainly live without that information.  However, I really do need to
know how to stop this from 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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: ActionMailer 3 does not generate a body from template

2010-10-25 Thread James Byrne
However, if I specify the template by calling the mail method with a do 
block and providing a render call to a non-existent template then I do 
get a template missing error raised.

What is going on here?  The API clearly states that if the mail method 
is called without a block then app/views are searched (presumably in a 
directory with the same name as the mailer class) for any files having 
the same stem name as the mailer method and ending in erb.  So, why no 
template error when the directory is missing?

I find that if I pass a block to the mail method and specify my template 
therein then, and only then, is the email body generated.  Is this the 
expected behaviour?  If so then the documentation is sadly misleading.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: ActionMailer 3 does not generate a body from template

2010-10-25 Thread James Byrne
I generated the new mailer using the rails3 rails g mailer name idiom. 
So, I assumed that the fact that a directory app/views/name indicated 
where I should put the template files.  However, removing this directory 
has absolutely no effect on ActionMailer.

At the very least I would expect it to raise a missing template error. 
But no, it behaves exactly as it has all along.  It creates headers but 
no body.  So, where is it looking for the templates and why on earth 
does it not fail if it cannot find them?

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] ActionMailer 3 does not generate a body from template

2010-10-25 Thread James Byrne
I am unable to generate a message body using ActionMailer 3.

This problem occurs even for ActionMailer classes and views that are
unchanged from Rails-2.3.  When these files are run with Rails 2.3
emails with bodies result.  When exactly the same files are used in a
Rails 3 project the headers are produced but no body.

I am at a loss to explain this.  Initially I thought that maybe the API
had changed in such a fashion as to drop the old template naming
convention.  However, having reworked these files to use the new api
exactly the same behaviour is observed, only headers are produced.

The new files are app/mailers/forex_mailer.rb and
app/views/forex_mailer/forex_cacb_update_notice.plain.erb

app/mailers/forex_mailer.rb contains this method

def forex_cacb_update_notice(
rates,
to_address = 'x...@example.com',
fm_address = 'y...@example.com' )
...
   mail( :to => recipients, :from => fm_address, :subject => subject )

The call used to invoke this mailer is:

   ForexMailer.forex_cacb_update_notice(rates, send_to).deliver


I therefore suspected that there must be something that has changed in
how the templates are parsed.  So, taking a hint from the API Readme I
changed the name of the template files from x.plain.rb to
x.text.plain.rb.  This had no effect.

As these templates are a mixture of fixed text and interpolated ruby
values I expected that I should see at least the fixed text portions of
the templates in the message body, but I am seeing nothing at all.
Inspection of the deliveries array shows this:

#, , , >,
, , ,
>
#
#


Does anyone have any idea why the message body is not being generated
from the templates provided?

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Rails 2 vs Rails 3 db:test:prepare oddness

2010-10-23 Thread James Byrne
This was caused by forgetfulness. When we switched to Rails3 we did so 
by generating a new Rails3 project and copying the .git directory from 
the Rails2 version and resolving the diffs.  But we missed setting 
config.active_record.schema_format = :sql.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Rails 2 vs Rails 3 db:test:prepare oddness

2010-10-20 Thread James Byrne
Marnen Laibow-Koser wrote in post #955846:

> As a former stored-procedure fan myself, I would strongly encourage you
> to move those into the application layer.  Maintenance of SPs is a
> nightmare, version control and testing are generally difficult to
> impossible, and they are generally just not worth the trouble.
>

This is not possible in a audit compliant environment.  And the 
generation of both functions and triggers in the production and 
development database is properly handled by the Rails-3 Active Record 
migration task.  The question at hand is: Is there a bug in the 
db:test:prepare task in Rails-3 or not?  If not then what need I do 
differently?

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Rails 2 vs Rails 3 db:test:prepare oddness

2010-10-20 Thread James Byrne
Reference: http://gist.github.com/636670

I use PostgreSQL in my project and I have triggers and functions defined
as Active Record migrations.  In Rails 2.3.10 this works exactly as
expected.  However, in Rails 3 it does not. The DBMS service is the same
in both cases so this variation is cause by some implementation change
in Rails-3.

The difference is that in Rails 2.3 the triggers and functions are
created by db:test:prepare and in Rails 3.0 they are not.  In both
Rails-2 and Rails-3 the development and production databases that are
created by db:migrate are identical, complete with the functions and
triggers.  However, Rails 3 db:test:prepare does not create the
functions or triggers in the test database at all.

This is a fairly significant failing and if it is a bug then I am very
surprised to discover it.  If I am doing something wrong then I would
like to know what it is.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: Re: Missing partials

2010-10-20 Thread James Byrne
Marnen Laibow-Koser wrote in post #955795:
> Colin Law wrote in post #955764:
> [...]
>> Actually it is obvious, look carefully at the Role Name line.  What is
>> it supposed to mean?
>>
>> Clue : and ' do not usually go together like that.
>
> Wrong.  :'Role Name: ' is perfectly legitimate syntax -- it's the way
> you type symbol literals that contain characters that aren't allowed in
> Ruby identifiers.  The meaning is more or less the same as 'Role Name:
> '.to_sym .
>
> It's probably not what the OP *wanted*, though. :)
>

Actually, that is an artifact of an earlier implementation which used 
embedded spaces.  I just never got around to removing the quote marks.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: Missing partials

2010-10-20 Thread James Byrne
James Byrne wrote in post #955754:

> I evidently have no idea how to get this to work in Rails3.  So, if
> anyone can see my obvious error then I would be grateful if you would be
> so kind as to point it out to me.

Well, it appears that all along the problem was one of a missing '=' as 
in:

<%= fields_for

instead of

<%- fields_for

And now everything works, even with :object => @role.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: Missing partials

2010-10-20 Thread James Byrne
Colin Law wrote in post #955669:
>
>
> You can use :locals
>

I have tried and I evidently am missing something that is obvious to 
others.  The partial I am calling has this:

<%- fields_for(role_header) do |ff| -%>
  <%= label role_header.class.to_s.downcase,
:rolename,
:'Role Name: ',
:class => :input_box_label,
:for => 'input_rolename' -%>
   


I have tried this:

<<%=form_for(@role, :html => {:id => :'new_role_form'}) do |f| %>

  <%=render   :partial  => 'role_header',
:locals => { 'role_header' => @role }-%>


And I get this:

 undefined method `model_name' for NilClass:Class 
(ActionView::Template::Error)
  
/home/byrnejb/.rvm/gems/ruby-1.8.7-p302/gems/activemodel-3.0.1/lib/active_model/naming.rb:90:in
 
`model_name_from_record_or_class'


I tried this:

  <%=render   :partial  => 'role_header',
:locals => { :role_header => @role }-%>

And got this:

cannot fill in, no text field, text area or password field with id, 
name, or label 'Role Name' found.


I tried this:

  <%=render   :partial  => 'role_header', @role-%>

And got this:

  compile error
  
/home/byrnejb/Software/Development/Projects/proforma.rails3/app/views/roles/new.html.erb:9:
 
syntax error, unexpected ')', expecting tASSOC
  ...tial  => 'role_header', @role);
^
  
/home/byrnejb/Software/Development/Projects/proforma.rails3/app/views/roles/new.html.erb:18:
 
syntax error, unexpected kEND, expecting ')'
  '); end
 ^
  
/home/byrnejb/Software/Development/Projects/proforma.rails3/app/views/roles/new.html.erb:26:
 
syntax error, unexpected kENSURE, expecting ')'


I evidently have no idea how to get this to work in Rails3.  So, if 
anyone can see my obvious error then I would be grateful if you would be 
so kind as to point it out 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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Missing partials

2010-10-19 Thread James Byrne
James Byrne wrote in post #955611:

>
> It appears that the partials are being called but that the model object
> is not being passed.

I discover here ( 
http://darwinweb.net/articles/getting-up-to-speed-with-rails-3 ) that 
the :object => syntax is no longer supported.  I suppose that I will 
eventually discover the current usage.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Missing partials

2010-10-19 Thread James Byrne
James Byrne wrote in post #955607:

>
> I added the snippet given above to a file in config/initializers called
> tattler.rb.  However, it does not work.  I get a stack trace when I run
> cucumber against the feature that previously simply failed.

I discovered my error that was causing tattler to fail.  This is what I 
get now:

http://gist.github.com/635479

It appears that the partials are being called but that the model object 
is not being passed.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Missing partials

2010-10-19 Thread James Byrne
Marnen Laibow-Koser wrote in post #955575:

>
> If the Tattler plugin works with Rails 3 (which I'm not sure of), you
> might want to use it to make sure that Rails thinks it's rendering the
> partials.
>

Tattler seems not to work but I found this in a post referring to it:

Tattler doesn't work with Rails 3 anymore. This little bit of code,
inspired by it, does.

unless Rails.env.production?
  class ActionView::Template
def render_with_comment(*args, &block)
  render_result = render_without_comment(*args, &block)
  if mime_type.nil? || mime_type === [Mime::HTML, Mime::XML]
("\n" +
 render_result +
 "\n"
).html_safe
  else
render_result
  end
end
alias_method_chain :render, :comment
  end
end


I added the snippet given above to a file in config/initializers called 
tattler.rb.  However, it does not work.  I get a stack trace when I run 
cucumber against the feature that previously simply failed.

http://gist.github.com/635417

So, I am no further ahead.  I looked into one of the missing partials. 
I do not notice anything obviously wrong.  The code is here:

http://gist.github.com/635423

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Missing partials

2010-10-19 Thread James Byrne
I am in the process of converting an application from RoR-2.3.10 to
3.0.1.  I have run across the situation where partials are not being
rendered at all, whereas the exact same code works fine in Rails2.  The
form code is:


<%- content_tag_for :h2, @role, :header do %>
  Add a New role <%= @role.id.to_s -%>
<%- end -%>
<%=error_messages_for :role %>
<%=form_for(@role, :html => {:id => 'new_role_form'}) do |f| %>

  <%= render  :partial  => 'role_header',
  :object   => @role -%>
  <%= render  :partial  => 'role_detail',
  :object   => @role -%>
  <%= render  :partial  => 'shared/effective_period',
  :object   => @role -%>
  
  <%=f.submit :Create,  :id => :submit_create -%>
  
<% end %>
.  .  .

All this generates is:


  



Is there anything wrong with using this syntax in Rails3?

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: Re: I need help with a design

2010-10-08 Thread James Byrne
Radhames Brito wrote:
> Because you have one user model i have 4, so when i authenticate i have to
> loop all the models to find the credentials beacuse there can be a
> company_user with name "pedro" and an admin name "pedro" because they are 2
> diferent models, there is another problem because those 2 pedros could have
> the same password, all because i am using different models for each user
> type.

>From what I have read I suggest that you reconsider what exactly a user 
is, what data is specific to a user and what data is specific to certain 
classes of users.  It seems to me, taking your statement above as a 
guide, that you are confused as to the actual arrangement of things in 
the real world.

First, there is, and can only every be, one real person with the 
identity 'pedro'.  There might be many people with similar names who are 
also known to your system but they are all different individuals.  In a 
computer system, indeed in any organized filing system, some method of 
distinguishing between individuals other than by common name is 
required.  Thus User IDs, SSNs, SINs, IRS IDs and so forth.  Whatever 
the case, a given individual should have only one identity in a system 
and a single system identity should only ever refer to one individual.

Second, the attributes of a company belong in something that is related 
to that society in its own right and not to any individual associated 
with it.

Third, the user membership of a society is a separate issue as well. 
Consider that userid pedro might work for two companies at once. Or 
might work first for one company and then for a different company. This 
is an association or state that is distinct from either the user or the 
company even if it is dependent upon both.

In a similar fashion, user pedro might have superuser privileges for one 
company but only user privileges for another.  As I understand your 
proposal this person would require an entry with one userid in the 
company-admin model and another in the company-user model and possibly 
even more entries for different company-user or company-admin model 
combinations. This is a maintenance nightmare that you are creating.

If instead you look at this from the point of view of entities and their 
relations then resulting data structure will be much more natural and 
will be easier to work with.  So something like:

User 1---n CompanyUser n---1 Company plus
   CompanyUser n---n UserRole  n---n Role n---n RoleRight n---1 
Right

Is likely a more flexible way to obtain the requisite functionality.  If 
you go with AuthLogic and Declarative Authorization then after these are 
wired into your app all you are left to implement with respect to RBAC 
is in essence just:

Company 1---n CompanyUser n---n UserRole

Which strikes me as a bit more manageable.

Devise is an authentication system.  The fact that it can be used to 
implement a primitive two-tier authorization system is a convenience for 
web apps that do not require a finer-grained approach to RBAC and wish 
to avoid the overhead of a full-featured RBAC implementation.  I cannot 
see Devise's authorization functionality dealing with anything very 
elaborate for the reasons that have been discussed at length in this 
thread. Namely, it either requires a separate User model or a separate 
User attribute for each and every role.

The bottom line is that you have asked for advice.  The advice that you 
are getting is uniformly against your chosen path.  That is not to say 
that our advice is perfect or that your approach will fail.  However, 
that seems the way to bet at the moment.
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: I need help with a design

2010-10-08 Thread James Byrne
Radhames Brito wrote:
> 
>  Authlogic is more flexible but it wont allow one page login for all 
> users easily. 
>

I do not understand what you mean by this.  I have authlogic in 
production where there is but one authentication view used by every 
user.  Each session created thereby has its own credentials and the user 
instance thereafter obtains its permissions from the 
declarative_authorization roles and rights configuration file.

I will not pretend that dealing with these two formidable packages was 
without its difficulties, particularly in the the beginning when my 
ignorance of them was complete.  However, once one grasps the concepts 
upon which each is based then elaboration of the resulting security 
system is far easier than I ever thought possible.

> Cancan requires a different ability per model so there is a lot  of
> redundancy when i need to define permissions for one type
> of user and  almost the same for another type of user. Thats why i have
> been thinking of joining everything in one model, but first i wanted
> ask to see if that was the best/only way to overcome all those obstacles.

I have not used CanCan (Ryan Biggs wrote that for one of his Railscasts 
episodes did he not?) but from what I can gather from your other 
messages it seems that you conflate authentication with authorization at 
several points.  Authlogic, Devise and similar packages simply identify 
a particular set of credentials as having a unique accessor instance in 
the system.  Declarative_Authorization and CanCan type packages tie 
access to specific bits of the application to specific accessor 
identities.  Both need some form of implementation of the idea of a 
session to be of much use.

My own experience with RBAC is that it proves best to stay away from 
things that you do not fully understand until you need to address them 
directly and can afford the time to master the intricacies involved. 
Imagining what you will need in the absence of concrete requirements is 
a great time waster.

For an initial implementation of authentication and authorization I 
would create some minimal methods in the application controller to 
handle hard coded identities, rights and roles and then go ahead build 
the application.  At some point the need for users will present itself 
and then you can implement your user models/classes modifying the stub 
methods to handle authorization alone.  When authorization becomes the 
natural focus of development then it is time to look at things like 
Authlogic and CanCan.

I think that you will find the this approach permits you to remain 
focused on the value-added part of your project and leaves the 
administrative pieces on the periphery until their requirements are 
largely defined by the rest of your application.


-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: I need help with a design

2010-10-07 Thread James Byrne
Radhames Brito wrote:
> I have been working on an app but ran into many problems when i was
> applying authentication and authorization.
> 
> I want to have the following users with the given abilities.
> 

Is there any reason that you cannot usefully employ existing 
authentication mechanisms like Auth_Logic or Devise?  And what about 
Declarative_Authorization? Is there any reason why this does not suit 
your authorization needs?

It seems to me to be a mis-application of effort to write from the 
ground up that which is already freely available and maintained for you.
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Where does one obtain the APU for Rails-2.3.9?

2010-10-07 Thread James Byrne
Philip Hallstrom wrote:

> You can get 2.3.8 from http://railsapi.com/ (click 'build your custom 
> package')
> 
> -philip

Thanks.  I also since discovered that

gem rdoc --all --overwrite

will create the missing rdoc files locally as 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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Unwanted page displays in tests but not in development

2010-10-07 Thread James Byrne
Rails 2.3.9
Ruby 1.8.7
Cucumber 0.9.2
Cucumber-Rails 0.3.2
Auth_Logic 2.1.6
Declarative_Authorization 0.5.1

My project uses AuthLogic for authentication using ActiveRecord session
store and DeclarativeAuthorization for access control.  I have a
requirement to provide a public interface to a particular query page
that requires no login.  Thus, there is no AuthLogic session created.

If the query is successful then the response is displayed on a show page
and if not then the original input form is redisplayed with suitable
notices.  On the show page a link is provided back to the query request
page to allow successive queries.

The cucumber steps for all this, up to the link to the query form from
the show page, work.  I can follow the new_request_path to the input
form using visit and there submit a successful request.  However, what
happens when I click on the link displayed on the resulting show page is
that I am sent to the default welcome page instead of back to the query
form. It turns out that this behaviour, showing the welcome page, was
happening all the time but that somehow the visit method then just
processed access to the unprotected page without complaint.

However, this display of the welcome page only happens while I am
testing. If I use the webrick server in development mode and I go to the
query page url directly then I do not see the welcome page.  Further,
when I enter a valid query. display the response page and then click on
the new query link then I go back to the query form without problem.
The welcome page is never displayed at all.

I am somewhat perplexed as to what might be happening here.  I note that
in development mode I have a session cookie notwithstanding that I have
no user session created.  Might my problem be somehow related to cookie
handling?  What is the present idiom to test Rails cookies?  The
examples I can find seem to be quite dated and, per my other topic, I
cannot seem to be able to check the 2.3.9 api for details.  I rather
suspect that the 3.0.0 api will not be very helpful.
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Where does one obtain the APU for Rails-2.3.9?

2010-10-07 Thread James Byrne
When I do a gem server the Rails entries do not provide rdoc entries and
the web references point to http://rubyonrails.org/ whose documentation
links point only to the rails-3.0.0 api so far as I can tell.

How does one install the rails rdoc files so that gem server can serve
them or how does one reach the 2.3.9 api online?
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Rails-2.3.8 routing question

2010-09-21 Thread James Byrne
I have a controller, customs_shipment_pars_checks_controller, that has
an action :new.  I wish to provide a shortcut url to this action tha
bypasses any frontend pages and embedded links.

In my routes.rb file I tried this:

  map.resource :parscheck,
:action => 'new',
:controller => 'customs_shipment_pars_checks'

Which, in my ignorance I thought would equal this url:

http://localhost:3000/customs_shipment_pars_check/new

But it does not.  Instead it is the equivalent of:

http://localhost:3000/customs_shipment_pars_check

Which fails with this:

NoMethodError in Customs_shipment_pars_checks#show

Now http://localhost:3000/parscheck/new works.

My question is how does one force a specific action (new) for a given
url using the #resource idiom?  What I want to be able to do is to have
someone enter http:/host/parscheck and have them presented with the new
template.  Do I have to do this instead?


  map.connect   'parscheck',
:action => 'new',
:controller => 'customs_shipment_pars_checks'
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: undefined local variable or method `start_form_tag'

2010-09-16 Thread James Byrne
Frederick Cheung wrote:

> It was deprecated in 1.2 and removed in 2.0
> 
> Fred

On the subject of error messages, with deprecations specifically in 
mind, I suggest the following approach at least be considered. 
Establish a deprecated_methods_index library at the top level of Rails 
so that, when someone finally decides to upgrade their Rails-1.0.6 app 
to Rails-whatever, instead of getting:

"undefined local variable or method `whatever'"
(which is generated by ruby itself and not by Rails)

one obtains the output from something like this:

def whatever(*parms)
  puts("whatever method is deprecated and was removed in rails-x.y.z.")
  puts("Use other_one method instead.")
end

If these are all kept in one place surely it would not be too difficult 
to maintain? Are there any downsides to this approach, other than having 
to write four lines of code for every deprecated method?
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: REST perhaps I don't undestand it.

2010-09-10 Thread James Byrne
Msan Msan wrote:
> On 10 September 2010 15:40, Sandy  wrote:
>>
>> �My routes.rb has �resources :rusers.
>> �Try putting the following line into routes.rb:
>> �map.connect 'user/logout', :controller => 'user', :action => 'logout'
> 
> ButI have to set a route for every custom action that I add to 
> controller?

Yes.  .  . and No.

If you insist on using a custom method in your controller then yes, you 
will have to specify a route for it.  However, you really should be 
looking at things from the point of view of utilizing only the basic 
crud actions of create, show, update and delete.

Consider what the verb logout implies.  Logout from what?  A session? 
Then what are we actually doing with respect to a session? Deleting it? 
Then perhaps the problem is that you really need another controller, say 
user_sessions_controller, and that the delete action in that controller 
is what should perform the logout action.

Keep in mind that in web applications speaking of logging in and out is 
at best a very shaky metaphor and not a description of what is really 
happening.  One does not log on to a web application, one creates an 
authenticated session.  So long as that session persists then the 
browser can consume the private resources provided by the web app.  Once 
the session is destroyed then the browser cannot consume those 
resources.

In my opinion, this is the secret to thinking about REST, putting 
everything in terms of the four basic verbs.  If you are thinking in 
terms of custom methods then you are probably not thinking REST.
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: rails3 routes.rb DSL deprecation warning

2010-09-10 Thread James Byrne
radhames brito wrote:
> gem cleanup  i think you have an old version of a dependency

I think that you were right.

Thank you.
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email 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 unexpected nil in assert_select

2010-09-10 Thread James Byrne
I have determined that this is indeed a webrat problem.  Evidently, 
webrat overrides assert_select in such a way as to break the Rails-3.0.0 
implementation.
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email 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 unexpected nil in assert_select

2010-09-10 Thread James Byrne
James Byrne wrote:

>> 
>> The response.body inside the step definition contains exactly what I
>> expect:
>> 
>>   
>>  To Proceed Please Authenticate Your Identity
>>   
>> 
>> What do I need to change to get this test to work in Rails-3.0.0?
> 
> Is there some place that lists the valid syntax for a css selector as 
> used by ActionDispatch?  I can only surmise that the argument value is 
> invalid for some reason.

I removed webrat-0.7.2-beta and tried again.  This eliminated the nil 
object error, so I infer that webrat caused this issue.  However, the 
test still fails.  Given this html:


To Proceed Please Authenticate Your Identity

and this assert_selector statement:

  expected = "#authorization_request"
  message = 'Missing authentication_request selector'

  assert_select(expected, message)

I receive this error:

Expected at least 1 element matching "#authorization_request", found 0.
is not true. (Test::Unit::AssertionFailedError)
  
/home/byrnejb/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/test/unit/assertions.rb:48:in
 
`assert_block'

As far as I can tell from my references, #authorization_request is a 
valid css selector.  So, why is this test failing in Rails-3?
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email 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 unexpected nil in assert_select

2010-09-10 Thread James Byrne
James Byrne wrote:

> 
> Running the cucumber feature that invokes this step generates the
> following error:
> 
>   undefined method `content_type' for nil:NilClass (NoMethodError)
>   /home/byrnejb/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/
> lib/active_support/whiny_nil.rb:48:in `method_missing'
>   /home/byrnejb/.rvm/gems/ruby-1.8.7-p302/gems/actionpack-3.0.0/
> lib/action_dispatch/testing/assertions/selector.rb:605:in
> `response_from_page_or_rjs'
>   /home/byrnejb/.rvm/gems/ruby-1.8.7-p302/gems/actionpack-3.0.0/
> lib/action_dispatch/testing/assertions/selector.rb:213:in
> `assert_select'
>   /home/byrnejb/Software/Development/Projects/proforma.git/
> features/app/models/users/step_definitions/
> user_authentication_steps.rb:56
> 
> The response.body inside the step definition contains exactly what I
> expect:
> 
>   
>  To Proceed Please Authenticate Your Identity
>   
> 
> What do I need to change to get this test to work in Rails-3.0.0?

Is there some place that lists the valid syntax for a css selector as 
used by ActionDispatch?  I can only surmise that the argument value is 
invalid for some reason.
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send 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 unexpected nil in assert_select

2010-09-09 Thread James Byrne
I am running cucumber features against a Rails 3 branch and I have this
step definition (which works fine in Rails-2.3.8):

When /should see (?:an|the) authentication request message/ do

  puts("This is the response: #{response.body}")

  selector = "#authentication_request"
  expected = true
  message = 'Missing authentication_request selector'

  assert_select(selector, expected, message)

end

Running the cucumber feature that invokes this step generates the
following error:

  undefined method `content_type' for nil:NilClass (NoMethodError)
  /home/byrnejb/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/
lib/active_support/whiny_nil.rb:48:in `method_missing'
  /home/byrnejb/.rvm/gems/ruby-1.8.7-p302/gems/actionpack-3.0.0/
lib/action_dispatch/testing/assertions/selector.rb:605:in
`response_from_page_or_rjs'
  /home/byrnejb/.rvm/gems/ruby-1.8.7-p302/gems/actionpack-3.0.0/
lib/action_dispatch/testing/assertions/selector.rb:213:in
`assert_select'
  /home/byrnejb/Software/Development/Projects/proforma.git/
features/app/models/users/step_definitions/
user_authentication_steps.rb:56

The response.body inside the step definition contains exactly what I
expect:

  
 To Proceed Please Authenticate Your Identity
  

What do I need to change to get this test to work in Rails-3.0.0?
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: rails3 routes.rb DSL deprecation warning

2010-09-09 Thread James Byrne
James Byrne wrote:
> During testing with Rails3 I am seeing this warning:
> 
> DEPRECATION WARNING: You are using the old router DSL which will be
> removed in Rails 3.1. Please check how to update your routes file at:
> http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/.
> (called from
> /home/byrnejb/Software/Development/Projects/proforma.git/config/environment.rb:5)
> 
> However, the contents of config/routes.rb are:
> 
> ProformaGit::Application.routes.draw do
>   resource :account
> end
> 
> What is causing this deprecation warning?  How do I get rid of it other
> than by turning the warnings off?

Does anyone have the answer to this and would care to enlighten me?  Is 
this a bug?
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] rails3 routes.rb DSL deprecation warning

2010-09-08 Thread James Byrne
During testing with Rails3 I am seeing this warning:

DEPRECATION WARNING: You are using the old router DSL which will be
removed in Rails 3.1. Please check how to update your routes file at:
http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/.
(called from
/home/byrnejb/Software/Development/Projects/proforma.git/config/environment.rb:5)

However, the contents of config/routes.rb are:

ProformaGit::Application.routes.draw do
  resource :account
end

What is causing this deprecation warning?  How do I get rid of it other
than by turning the warnings off?
-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: ActionMailer task in cron

2009-07-27 Thread James Byrne

James Byrne wrote:

> 
> I have discovered that I get the same behaviour as observed in cron in a 
> session if I set RAILS_ENV='production'.

I have uncovered two more things.

1. If the delivery method is set to 'smtp' then delivery fails with teh 
error given above.

2. The delivery method must be set in production.rb to have effect.  I 
am not sure why because the setup that I had worked in test and 
development.

-- 
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: ActionMailer task in cron

2009-07-27 Thread James Byrne

James Byrne wrote:
> I have a Ruby script that sends an email.  It works perfectly well when
> run from the command line of a user session, wheter in development or
> test mode.  When run by cron as the same user however, it fails with
> this:
> 

I have discovered that I get the same behaviour as observed in cron in a 
session if I set RAILS_ENV='production'.

-- 
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] ActionMailer task in cron

2009-07-27 Thread James Byrne

I have a Ruby script that sends an email.  It works perfectly well when
run from the command line of a user session, wheter in development or
test mode.  When run by cron as the same user however, it fails with
this:

/usr/lib/ruby/1.8/net/smtp.rb:680:in `check_response': 501 5.0.0 HELO
requires domain address (Net::SMTPSyntaxError)
  from /usr/lib/ruby/1.8/net/smtp.rb:653:in `getok'
  from /usr/lib/ruby/1.8/net/smtp.rb:623:in `helo'
  from /usr/lib/ruby/1.8/net/smtp.rb:401:in `do_start'
  from /usr/lib/ruby/1.8/net/smtp.rb:378:in `start'
  from
/usr/lib64/ruby/gems/1.8/gems/actionmailer-2.3.3/lib/action_mailer/base.rb:681:in
`perform_delivery_smtp'
  from
/usr/lib64/ruby/gems/1.8/gems/actionmailer-2.3.3/lib/action_mailer/base.rb:523:in
`__send__'
  from
/usr/lib64/ruby/gems/1.8/gems/actionmailer-2.3.3/lib/action_mailer/base.rb:523:in
`deliver!'
  from
/usr/lib64/ruby/gems/1.8/gems/actionmailer-2.3.3/lib/action_mailer/base.rb:395:in
`method_missing'
  from
/home/byrnejb/Software/Development/Projects/proforma.git/app/controllers/mail_notice_fx_cacb.rb:6:in
`email_fx'
  from ./bin/../lib/forex/hll_forex_ca_feed.rb:114:in `execute'
  from bin/forex:5

I use a config/email.yml file that is defined thus:

test:
  delivery_method: :smtp
  smtp_settings:
address: smtp.harte-lyne.ca
port: 25
domain: harte-lyne.ca

production:
  delivery_method: :smtp
  smtp_settings:
address: smtp.harte-lyne.ca
port: 25
domain: harte-lyne.ca

development:
  delivery_method: :smtp
  smtp_settings:
address: smtp.harte-lyne.ca
port: 25
domain: harte-lyne.ca

and is loaded via config/initializers/load_email_config.rb which looks
like this:

# Load mail configuration if not in test environment
if RAILS_ENV != 'test'
  email_settings =
YAML::load(File.open("#{RAILS_ROOT}/config/email.yml"))
  ActionMailer::Base.smtp_settings =
email_settings[RAILS_ENV] unless email_settings[RAILS_ENV].nil?
end

I have placed puts in the initializer file and I can see it being
called, but the puts display after the eerror so it seems to me that
perhaps the email is being sent before the settings are.

For example, if I place puts before the RAILS_ENV and before each
statement within the conditional then I see this:

usr/lib/ruby/1.8/net/smtp.rb:680:in `check_response': 501 5.0.0 HELO
requires domain address (Net::SMTPSyntaxError)
  from /usr/lib/ruby/1.8/net/smtp.rb:653:in `getok'
  from /usr/lib/ruby/1.8/net/smtp.rb:623:in `helo'
  from /usr/lib/ruby/1.8/net/smtp.rb:401:in `do_start'
  from /usr/lib/ruby/1.8/net/smtp.rb:378:in `start'
  from
/usr/lib/ruby/gems/1.8/gems/actionmailer-2.3.3/lib/action_mailer/base.rb:681:in
`perform_delivery_smtp'
  from
/usr/lib/ruby/gems/1.8/gems/actionmailer-2.3.3/lib/action_mailer/base.rb:523:in
`__send__'
  from
/usr/lib/ruby/gems/1.8/gems/actionmailer-2.3.3/lib/action_mailer/base.rb:523:in
`deliver!'
  from
/usr/lib/ruby/gems/1.8/gems/actionmailer-2.3.3/lib/action_mailer/base.rb:395:in
`method_missing'
  from
/var/data/theheart/releases/20090727153549/app/controllers/mail_notice_fx_cacb.rb:6:in
`email_fx'
  from ./bin/../lib/forex/hll_forex_ca_feed.rb:114:in `execute'
  from bin/forex:5
Loading email config
Reading email config
Setting smtp defaults

The script has this in it:

#!/usr/bin/env ruby
require File.dirname(__FILE__) +
'/../lib/forex/hll_commercial_forex_notify'
HLLCommercialForexNotify::Main.new(ARGV).execute

And, the script class does this:
...
  unless defined? RAILS_DEFAULT_LOGGER
require File.dirname(__FILE__) + '/../../config/environment'
  end
  require 'hll_commercial_forex_rates_notice'
...

Can anybody tell me what I am doing wrong?
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: rake error

2009-07-20 Thread James Byrne

jko170 wrote:
> I enter the command and press enter and nothing happens.
> 
> On Jul 20, 5:56�pm, James Byrne 

Then the ruby vm is not starting properly, and as Rake is a ruby script 
it fails in consequence.  Resolve what has happened with your ruby 
installation and the Rake problem is likely resolved as 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: rake error

2009-07-20 Thread James Byrne

jko170 wrote:
> Nothing is outputted. It just loads forever.

What exactly do you mean by, "It just loads forever".  Status 1 from a 
ba shell means that the returning processed failed for some reason.  If 
your ruby binary has had its permissions changed, or it has been moved, 
or corrupted in some way then this could be your problem.

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

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



[Rails] Re: rake error

2009-07-20 Thread James Byrne

jko170 wrote:
> When I run rake test:units I get this error:
> 
> 292 tests, 350 assertions, 2 failures, 13 errors
> rake aborted!
> Command failed with status (1): [/usr/local/bin/ruby -I"lib:test" "/
> usr/loc...]
> 
> This error just showed up yesterday --- I have no idea how I caused
> it. Here is my gem list in case that helps:

What happens when you do this from the shell?

$ /usr/local/bin/ruby
-- 
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: Routing error

2009-07-19 Thread James Byrne

Dwight Shackelford wrote:

> 
> Well, cookbook is not one I wrote, but sometimes it is the only one 
> Mongrel will start for.  I just thought that it started Mongrel.  Didn't 
> know it was starting it specifically for a certain subdirectory.
> 
> What is the mechanism behind that?  What do I check to see where Mongrel 
> is listening?
> 
> I started two weeks late into a 5 week class.  What you're witnessing is 
> thrashing.

Start here: 
http://www.tutorialspoint.com/ruby-on-rails/rails-introduction.htm

READ it all.  It is old and out of date, but is so generic that this 
barely matters. Then, either set up a Rails project from scratch 
following the tutorial or connect with somebody that has at least a 
passing familiarity with the framework and have them do it with you.

If mongrel will not start for any project other than cookbook then your 
problem is that each of the other projects has a fatal error that 
prevents the server from starting.  When this happens the cause is sent 
to stderr which, if you are starting it from a virtual terminal session, 
will be your display.  Follow the stack trace to locate the problem.

But, do the tutorial first.
-- 
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: Routing error

2009-07-19 Thread James Byrne

Dwight Shackelford wrote:
> 
> InstantRails has a button that says "Start project with Mongrel".  I'll 
> sometimes hit that, just to get Mongrel listening, then from the web 
> page pull up different projects.  Not sure if that's the issue or not.

Just to double check the obvious, when you start the mongrel cluster are 
you sure that you are starting it in the correct (cookbook) project root 
directory every time?
-- 
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: Routing error

2009-07-19 Thread James Byrne

Dwight Shackelford wrote:
> I wiped the logs, because data from differing projects were getting 
> written to multiple logs, meaning a specific log under a specific 
> subdirectory included data from other projects too.  To get a clean run, 
> I truncated them.  Cookbook runs now.  Phonebook did not, and no log was 
> written for the attempt to run it.  Not that I can find.

I am curious about this statement.  How did you arrange to have 
different projects write to the same log/development log?  You do not 
have multiple Rails projects in the same root directory perchance?
-- 
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: authentication and authorization

2009-07-19 Thread James Byrne

Rajendra Bayana wrote:
> hi, i want some information about the pluing's available for
> authentication and authorizations.
> 
> can any one tell me what are the plugins available in ROR for
> authentication and authorization. suggest me which is best one.

I suggest that you at least consider these:

Authentication:
http://github.com/binarylogic/authlogic/tree/master

Authorisation:
http://github.com/stffn/declarative_authorization/tree/master
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Execute Ruby Script

2009-07-15 Thread James Byrne

Marnen Laibow-Koser wrote:
> James Byrne wrote:

> 
> No.  You'd be better off using require or similar.
> 

That really depends upon the question being asked.  The OP explicitly 
asked on how to run an external script, that happened to be written in 
Ruby; not, what is the best way to run arbitrary external ruby code from 
inside a running Ruby script?

If the latter case then I suggest that the OP consider this approach, 
which was recently shown to me by Matt Wynne on the Cucumber list:

First, write the script and encapsulate its entire code within an 
execute method contained in a Script class file. Like so:

script.rb
class Script  # should be the actual name of the script.
  def initialize(argv)  # receive the ARGV array from the calling 
process
@argv = argv
  end
  def execute
# if required then parse any command line arguments in @argv here
puts "script.rb called"
  end
end
#eof

If a stand-alone script initiation is required, as with cron say, then 
write a stub script that calls the script class and executes the script 
code like so:

runner.rb
#!/usr/bin/env ruby
require 'script'

Script.new(ARGV).execute
#eof

If the encapsulated script is complex enough that it contains its own 
internal classes then the whole can be encapsulated inside an outer 
class given the script name. The inner class containing the execute 
method is then renamed to something like Main. In this case the call 
becomes:

Script::Main.new(ARGV).execute

And the class file script.rb has this structure

class Script

  class Main
def initialize(argv)
  @argv = argv
end
def execute
  script code goes here
end
  end

  class OtherClass
...
  end
end

One may now use the script within any other ruby process as you suggest, 
via a simple require and subsequent instantiation.  I found this 
technique extremely valuable in testing since out of process scripts did 
not share the dbms state with the the test harness.








-- 
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] Passing a DB connection between scripts

2009-07-13 Thread James Byrne

I am attempting to test a stand-alone script.  I wish to call the script
from inside the test framework, passing it a variety of command line
arguments, and verify the results.

The difficulty I have is that the testing framework I am using,
cucumber, holds db updates inside an incomplete db transaction.  It
thereby avoids the processing cost of an actual commit while easily
resetting the db for the next test by performing a rollback at the end
of the present test.

In this situation, opening a new instance of the script via the backtick
kernel method creates a new db connection.  Since this is a different
connection from that opened by the test framework, incomplete
transactions are invisible to it and so the script fails, because the
test data is not available.  What I would like to do is to execute the
script inside the existing Ruby instance and inherit the DB connection.
This I cannot figure out how to accomplish.  I thought that simply
"load"ing the script would suffice, but no.  In this case it evidently
neither opens its own connection nor inherits the existing one for I
receive this error at the load statement.

  PGError: not connected: ROLLBACK (ActiveRecord::StatementInvalid)
  
/usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract_adapter.rb:212:in
`log'

Does anyone have any ideas on how I can accomplish what I desire?
-- 
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: link_to, how do you combine url options and html_options?

2009-07-09 Thread James Byrne

Matt Jones wrote:

> 
> The example that I think several of the previous posters were thinking
> of (splitting the two arrays with {}) is typically encountered with
> form_for; but note that form_for takes URL parameters with the :url
> key.

I think that this is what happened to me.  I encountered a similar hell 
when trying (eventually successfully) to get html attributes properly 
assigned to a select method inside a forms_for method.  Given the 
similarity of usage and signatures, I extrapolated that (unpleasant) 
previous experience into this method as 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: link_to, how do you combine url options and html_options?

2009-07-08 Thread James Byrne

Älphä Blüë wrote:
> <%= link_to('Your Link', your_controller_path, :confirm => 'Are you 
> sure?', :method => :post, :id => "css_id", :class => "css_class") %>

Thank you to all who replied.  I am on Rails 2.3.2 and yes, the code 
above does work for me as well.  I cannot gather from the API documents 
that this should work however, which is why I never tried it.
-- 
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: link_to, how do you combine url options and html_options?

2009-07-07 Thread James Byrne

James Byrne wrote:

> But we were so close. The actual code has to be this:

That code does not work either. It does not generate an error but now I 
am back to having the id and class attributes set in the  tag, but 
not the onclick.

Arrrgggh

-- 
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: link_to, how do you combine url options and html_options?

2009-07-07 Thread James Byrne

James Byrne wrote:
On Jul 7, 3:12�pm, James Byrne 
> 
> Presuming that you actually meant the closing ) to be a } I had already 
> tried that.  This is what happens:
> 
> 
> <%=link_to('link here',
> { new_object_path,
>   :method=>  :post,
>   :confirm   =>  "Press OK"},
> :id => "css_id")
> %>
> 
>
But we were so close. The actual code has to be this:

<%=link_to('link here',
 { new_object_path,
   { :method=>  :post, # note hash within block
 :confirm   =>  "Press OK"
   }
 },
 :id => "css_id")
%>

Obscure does not do this sort of thing justice.
-- 
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: link_to, how do you combine url options and html_options?

2009-07-07 Thread James Byrne

Nicholas Henry wrote:
> Based on the documentation:
> 
> link_to(name, options = {}, html_options = nil)
> 
> I would expect this is what you are looking for (note haven't tested
> it):
> 
> link_to "link here", {new_object_path,
> :method => :post, :confirm => 'Press OK'), #url
> options
> :class => "css_class", :id => "css_id"#html
> options
> 
> HTH,
> Nicholas
> 
> On Jul 7, 3:12�pm, James Byrne 

Presuming that you actually meant the closing ) to be a } I had already 
tried that.  This is what happens:


<%=link_to('link here',
{ new_object_path,
  :method=>  :post,
  :confirm   =>  "Press OK"},
:id => "css_id")
%>


compile error
index.html.erb:86: syntax error
  :method=>  :post,
   ^
index.html.erb:87: syntax error
  :confirm   =>  "Press OK"},

index.html.erb:89: syntax error
).to_s); @output_buffer.concat "\n"
   ^

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

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



[Rails] link_to, how do you combine url options and html_options?

2009-07-07 Thread James Byrne

I have a link-to that I wish to look somewhat like this:


link_to "link here", new_object_path,
:method => :post, :confirm => 'Press OK', #url
options
:class => "css_class", :id => "css_id"#html
options

In any case I can either get the url_for options to work or the html
options to work, but no matter how I arrange () or {} I cannot get both
to work together.  As far as I can determine, the api documents do not
explicitly show this case either.

What I want link_to to generate is:

link here

 How is this done?
-- 
Posted via http://www.ruby-forum.com/.

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



  1   2   3   >