[Rails] why can't I add a :class to text_field?

2009-06-07 Thread Zhenning Guan

<%= text_field_tag 'login' ,nil, {:class => 'line'} %>
 the old way work.



<%= f.text_field :login, :class => 'line' %>
 but why this doesn't.
-- 
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] Remove special characters from sentence

2009-06-07 Thread Sandip Ransing
Hi All,

What is regular expression to remove special chars from a sentence and
replace spaces with hypen ??


Thanks,
Sandip R~
-- 
Ruby on Rails Developer
http://sandip.sosblog.com
http://funonrails.wordpress.com
www.joshsoftware.com

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



[Rails] Inner Join help

2009-06-07 Thread Scott Holland

Hello!

I want to limit my model to just show companies from the current users
account:

user.account.companies

I have this in my model which seems to be working:

def self.find(*args)
args << {:conditions => X"}
super
end


Now I just need to turn this sql into rails conditions:


SELECT `companies`.* FROM `companies` INNER JOIN `users` ON
`companies`.user_id = `users`.id WHERE ((`users`.account_id = 1))

Can anyone help with this?

Thanks

Scott
-- 
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 Classes

2009-06-07 Thread J. D.

Hi Fred,

I think I will use this for my find parameter:

start_date = Time.now.beginning_of_week
end_date = Time.now.end_of_week
@rushing_offenses = RushingOffense.find(:all, :conditions => 
['created_at > ? and created_at < ?', start_date, end_date])

That will let me find anything created within the set week.  Now I just 
have to figure out how to check whether or not it returns nil and create 
data..

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

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



[Rails] Re: Deployment Question

2009-06-07 Thread Maurício Linhares

Don't use the glassfish app server for that, it's overkill, use a
lightweight solution like jetty -> http://jetty.mortbay.com/

Download the binary, generate a war file for your project using
warbler and then copy the .war file to the "your jetty install
folder"/webapps. Start jetty and the application should be available
at "http://localhost:8080/war_file_name";.

-
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) |
http://codeshooter.wordpress.com/ (en)



On Sun, Jun 7, 2009 at 7:16 PM, Vivek Pandey wrote:
> To host multiple applications, on the same server, you should be using the
> glassfish application server (not glassfish gem).
>
> So , let say you have a running glassfish v3 server and lets say you have
> two apps in directories
>
> ~/apps1
> ~/apps2
>
> You would deploy them as:
>
>
> asadmin deploy ~/apps1
> asadmin deploy ~/apps2
>
> Then you can access these apps at, http://localhost:80/apps1/ and
> http://localhost:80/apps2/
>
> You also have option to package the Rails app as WAR file and deploy on
> GlassFish server. See warbler doc,
> http://caldersphere.rubyforge.org/warbler/.
>
> -vivek.
>
>
> On Sun, Jun 7, 2009 at 11:30 AM, JannaB  wrote:
>>
>> If I am using only Glassfish, and deploying to say, port 80 how
>> can I handle multiple sites (multiple rails root dirs) on the same
>> machine? -JannaB
>>
>> On Jun 5, 1:12 pm, Vivek Pandey  wrote:
>> > > Vivek, you might want to create a screencast on how to deploy a Rails
>> > > application
>> > > using JRuby and Glassfish.  This will be helpful to others that want
>> > > to use
>> > > JRuby
>> > > as well as disprove some of the negative myths attached to it.
>> >
>> > There are several articles/blogs/wikis entries that describe running
>> > Rails
>> > on GlassFish server as well as glassfish gem.
>> >
>> > To get started see Charles Nutter blog on "Easy deployment with
>> > Glassfish
>> > gem"
>> > at:http://blog.headius.com/2009/04/apache-jruby-rails-glassfish-easy.html
>> >
>> > I should have a new screen cast on Deployment of Rails/Merb/Sinatra on
>> > GlassFish gem soon.
>> >
>> > -vivek.
>> >
>> >
>> >
>> > > -Conrad
>>
>
>
> >
>

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

2009-06-07 Thread Maurício Linhares

You can't and shouldn't be doing this inside a controller. Just do it
in the view.

-
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) |
http://codeshooter.wordpress.com/ (en)



On Mon, Jun 8, 2009 at 12:01 AM, Valen
Onish wrote:
>
> I need to use 'link_to' dynamically in my view.
>
> So, in my controller I wrote:
>
> �...@right_part = " <%= link_to( 'Next', :action => '/index', :id => 3)%>"
>
> And in my view I'm trying to get a link:
>
>  <%= @right_part %>
>
>
> But all this doesn't work. Help 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] link_to from controller

2009-06-07 Thread Valen Onish

I need to use 'link_to' dynamically in my view.

So, in my controller I wrote:

  @right_part = " <%= link_to( 'Next', :action => '/index', :id => 3)%>"

And in my view I'm trying to get a link:

  <%= @right_part %>


But all this doesn't work. Help 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: ActiveRecord Classes

2009-06-07 Thread J. D.

By the way Fred,

I really do appreciate you taking the time to help me and isolate some 
of my issues.  I want to be proactive with my own code and later on with 
helping others.  My goal is to gain an understanding of best practice 
methods and start utilizing those methods in my code from the start.

I want to do whatever it is I need to do to get things going.  If you 
say I need to go to X site (I'll go to X site), etc.

I'm very focused at the task at hand.

-- 
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 Classes

2009-06-07 Thread J. D.

Frederick Cheung wrote:
> 
> Sounds like you shouldn't be using update_all at all here, rather you
> should be using find to find an appropriate row to update and if there
> is none, create a new one.
> 
> Fred

Again, the problem is I don't know how.  I'm simply guessing based on 
what I see with the documentation.  I don't have any working examples 
and most of the tutorials I see are very basic..

How I plan to manage the data is important as well.

For instance, I want to keep weekly data snapshots.  So, as an example 
just using the rushing offense table:

A user will be able to check by a particular week (the cron job will run 
the rake task once per week)

Therefore, my database table needs to account for "new data" every 
single week.

Scenario:

Rake Task begins
Check for weekly snapshot data (for current week)
-- If no snapshot data then create it
-- If data already exists for current week do nothing
Next Week
Rake Task begins
Check for weekly snapshot data (for current week)
-- If no snapshot data then create it
-- If data already exists for current week do nothing

So, let's look at my current table structure:

:rank
:name
:games
:carries
:net
:avg
:tds
:ydspg
:wins
:losses
:ties

So, the first issue I see is that I do not have a column that accounts 
for some type of weekly snapshot event notification.  Would you 
recommend this be tied to a timestamp?  How would I check (based on the 
conditions above) to check against a particular timestamp range and 
produce the results..?

Or should I create another column to check this out?

And, lastly, is there somewhere online that code is available to view 
for "advanced table manipulation"?  Much of the code that I have found 
is either very outdated, very basic, or not something I can use.  The 
documentation is a decent start but it does not contain a lot of 
advanced examples..

I know I may be asking a lot of questions (and I apologize if I am). 
However, I do learn quickly and I'm the type of person that likes to 
dive in and get started.  I've read one full ruby book and am midway 
through my first rails book.  However, even these books do not provide 
me scenario based examples.

This is why I'm here.  I am better at understanding code when I see 
code.  I don't mind working through code that contains errors and trying 
to get it to work.  That just helps me gain an understanding of what 
occurs.  The API can only be used as a code bits reference.  I always 
look there first but which code are you looking for?  If you know 
exactly what method you are going to be working with, looking in the API 
and then scouring the web for information is a little easier.  In the 
case of my example above, I'm not sure which methods I will be working 
with exactly to accomplish my task.

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

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



[Rails] Re: Ruby w/ Apache mod_proxy

2009-06-07 Thread Rick DeNatale

On Sun, Jun 7, 2009 at 8:25 PM, JannaB wrote:
>
> But that's not what I want. I need Apache listening on port 80,
> routing it to the glassfish gem running on 81 (or any other port other
> than 80)

I think you need to understand how Apache virtual hosts work,
particularly the difference between ip based and name-based vhosts:

http://httpd.apache.org/docs/2.2/vhosts/name-based.html

-- 
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

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

2009-06-07 Thread Frederick Cheung



On Jun 8, 12:22 am, "J. D."  wrote:
> Hi Fred,

> puts "Updating Team Name = #{offensive_rushing.rows[i][1]}."
> --> Print me out an update to show me that you are updating the teams
> RushingOffense.update_all(:name => offensive_rushing.rows[i][1],
>         :games => offensive_rushing.rows[i][2])
> --> Update the :name with the name of the team
> --> Update the :games with the number of games that team has played
> --> Update it if the team already exists (not sure how to do this part)
> --> Add new data if the team doesn't exist (don't know how to do this
> part)

Sounds like you shouldn't be using update_all at all here, rather you
should be using find to find an appropriate row to update and if there
is none, create a new one.

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



[Rails] Re: Use of Models - The Very Basics

2009-06-07 Thread Marnen Laibow-Koser

Doug Jolley wrote:
[...]
> Do we only use models with databases or do they have other uses?

They certainly have other uses. Models represent any domain object that 
you need.  Sometimes these objects will correspond to DB records, 
sometimes not.

> 
> Models descend from ActiveRecord::Base.  That certainly gives rise to
> a notion that models are used exclusively with databases.
[...]

The Rails community often gives the impression that models have to 
descend from ActiveRecord::Base, but that's only true *if you need 
ActiveRecord features*.  True, most models in Rails apps tend to inherit 
from AR.  However, if you're modeling something that doesn't interact 
with the DB, there's generally no need to inherit from AR, but the class 
is still a model because it represents a domain object.
In other words, whether a class is considered a model has to do with the 
*conceptual* niche that it fills within the app, not with whether it 
inherits from AR.

Does that help?

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Ruby w/ Apache mod_proxy

2009-06-07 Thread JannaB

But that's not what I want. I need Apache listening on port 80,
routing it to the glassfish gem running on 81 (or any other port other
than 80)

On Jun 7, 12:28 pm, Rick DeNatale  wrote:
> On Sun, Jun 7, 2009 at 9:37 AM, JannaB wrote:
> > So I am trying to mod_proxy the site to the url with port 81 that I
> > know works. Here is how I have the VirtualHost in my httpd.conf file
> > set up:
>
> > 
> >    ServerName gg
> ...
> > 
>
> ...
>
> > whenever I go to hithttp://127.0.0.1/ggI get a 404 not found error.
> > I am certain my document root is correct. Can you fellows here who
> > have done this tell me what I am missing? Thanks, Janna B.
>
> The servername ofhttp://127.0.0.1/ggis not gg but 127.0.0.1 so I'm
> pretty sure that the virtualhost directive isn't having any effect for
> the request.
>
> I'd try adding an entry in /etc/hosts to map gg to 127.0.0.1  and then
> point the browser at
>
> http://gg
>
> and see what happens
>
> --
> Rick DeNatale
>
> Blog:http://talklikeaduck.denhaven2.com/
> Twitter:http://twitter.com/RickDeNatale
> WWR:http://www.workingwithrails.com/person/9021-rick-denatale
> LinkedIn:http://www.linkedin.com/in/rickdenatale
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: embed php code in rails

2009-06-07 Thread Marnen Laibow-Koser

istar...@gmail.com wrote:
[...]
> Oh, and where are the php error log files
> located?

PHP generally puts its errors into the Apache server's error log, if I 
remember correctly.

> 
> Thank you,
> 
> Frank

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: ActiveRecord Classes

2009-06-07 Thread J. D.

Hi Fred,

Yeah I'm stuck with this one.  I've checked the documentation but I'm 
just not following it.

What I basically need it to do is to update the table with the data 
that's parsed into @rows.

In this case @rows is listed by:

offensive_rushing.rows[i][1] (:name)
offensive_rushing.rows[i][2] (:games)

I was trying to do a for loop to go through all of the rows and send the 
new data to the database.  I'm just not sure how to do it properly.  I 
catch on quick but I've been searching the web and reading the 
documentation and I just don't see a very detailed model for what I'm 
trying to do.

So, in a readability format what I see is:

for i in 0..offensive_rushing.numrows-1
--> starting my loop and it's going to repeat approx 120 times (120 
teams)
puts "Updating Team Name = #{offensive_rushing.rows[i][1]}."
--> Print me out an update to show me that you are updating the teams
RushingOffense.update_all(:name => offensive_rushing.rows[i][1],
:games => offensive_rushing.rows[i][2])
--> Update the :name with the name of the team
--> Update the :games with the number of games that team has played
--> Update it if the team already exists (not sure how to do this part)
--> Add new data if the team doesn't exist (don't know how to do this 
part)

I hope that helps..

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

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



[Rails] Re: Missing Template when testing with the Brain Buster Captcha partial

2009-06-07 Thread Matt W.

Just to experiment, I used this instead:

<%= render :partial => "#{RAILS_ROOT}/vendor/plugins/brain_buster/
views/brain_busters/captcha.html.erb" unless action_name == 'edit' %>

and now I get the following error:

ActionView::TemplateError: Called id for nil, which would mistakenly
be 4 -- if you really wanted the id of nil, use object_id
On line #4 of vendor/plugins/brain_buster/views/brain_busters/
_captcha.html.erb

1: <% unless captcha_passed? %>
2:  
3:
4:  <%= hidden_field_tag :captcha_id, @captcha.id
%>
5:
6:  
7:  Spam protection: <%= @captcha.question
%>

vendor/plugins/brain_buster/views/brain_busters/
_captcha.html.erb:4
app/views/contacts/_form.html.erb:23
app/views/contacts/_form.html.erb:1
app/views/contacts/edit.html.erb:1
app/controllers/contacts_controller.rb:41:in `update'
functional/contacts_controller_test.rb:80:in
`__bind_1244416417_125477'
/usr/local/lib/ruby/gems/1.8/gems/thoughtbot-shoulda-2.10.1/
lib/shoulda/context.rb:271:in `call'
/usr/local/lib/ruby/gems/1.8/gems/thoughtbot-shoulda-2.10.1/
lib/shoulda/context.rb:271:in `run_current_setup_blocks'
/usr/local/lib/ruby/gems/1.8/gems/thoughtbot-shoulda-2.10.1/
lib/shoulda/context.rb:270:in `each'
/usr/local/lib/ruby/gems/1.8/gems/thoughtbot-shoulda-2.10.1/
lib/shoulda/context.rb:270:in `run_current_setup_blocks'
/usr/local/lib/ruby/gems/1.8/gems/thoughtbot-shoulda-2.10.1/
lib/shoulda/context.rb:252:in `test: on PUT to :update with invalid
params should assign @contact with a kind of Contact. '
/usr/local/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run'
/usr/local/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each'
/usr/local/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run'
/usr/local/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run'
/usr/local/lib/ruby/1.8/test/unit/testsuite.rb:33:in `each'
/usr/local/lib/ruby/1.8/test/unit/testsuite.rb:33:in `run'
/usr/local/lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:
46:in `run_suite'
/usr/local/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:
67:in `start_mediator'
/usr/local/lib/ruby/1.8/test/unit/ui/console/testrunner.rb:
41:in `start'
/usr/local/lib/ruby/1.8/test/unit/ui/testrunnerutilities.rb:
29:in `run'
/usr/local/lib/ruby/1.8/test/unit/autorunner.rb:216:in `run'
/usr/local/lib/ruby/1.8/test/unit/autorunner.rb:12:in `run'
/usr/local/lib/ruby/1.8/test/unit.rb:278
functional/contacts_controller_test.rb:88

I feel like after that point I'm just chasing the white rabbit, seems
that once I figure out the initial problem, things should be okay.

On Jun 7, 2:27 pm, Rob Biedenharn  wrote:
> Take off the slash?
>
>    <%= render :partial => 'captcha' unless action_name == 'edit' %>
>
> -Rob
>
> Rob Biedenharn          http://agileconsultingllc.com
> r...@agileconsultingllc.com
>
> On Jun 7, 2009, at 12:22 AM, Matt W. wrote:
>
>
>
> > When I run my functional tests, they throw an error with the following
> > message:
>
> > ActionView::TemplateError: Missing template /_captcha.erb in view path
> > app/views:test/vendor/plugins/brain_buster/views/brain_busters
> >    On line #23 of app/views/contacts/_form.html.erb
>
> >        20:     <%= f.label :message %>
> >        21:     <%= f.text_area :message %>
> >        22:   
> >        23:   <%= render :partial => '/captcha' unless action_name ==
> > 'edit' %>
> >        24:   <%= f.submit "Submit" %>
> >        25: <% end %>
>
> >        app/views/contacts/_form.html.erb:23
> >        app/views/contacts/_form.html.erb:1
> >        app/views/contacts/edit.html.erb:1
> >        app/controllers/contacts_controller.rb:41:in `update'
>
> > I've checked to make sure the partial is in the right location, it is
> > in this directory:
>
> > /vendor/plugins/brain_buster/views/brain_busters/_captcha.html.erb
>
> > Any ideas as to why the test can't find the partial? It works fine
> > when I test it manually (via the browser).
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email 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 Classes

2009-06-07 Thread Frederick Cheung



On Jun 8, 12:02 am, Frederick Cheung 
wrote:
> On Jun 7, 10:01 pm, "J. D."  wrote:
>
>
>
> > Any ideas of what I might be doing wrong?
>
> You're not using update_all correctly - check the documentation
>
Well the documentation may not mention the usage you are using, but it
does exist, sorry about that. You do seem to be using it slightly
oddly though: you call update_all multiple times, but you don't
specify any conditions, so each call to update_all overwrites the
changes made by the previous one.

Fred
> Fred
>
>
>
> > This still has been a great day because even though I've seen tons of
> > errors, I'm learning..
>
> > --
> > Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Missing Template when testing with the Brain Buster Captcha partial

2009-06-07 Thread Matt W.

Thanks, but unfortunately, that had no affect…have you ever run into
this kind of thing before?

On Jun 7, 2:27 pm, Rob Biedenharn  wrote:
> Take off the slash?
>
>    <%= render :partial => 'captcha' unless action_name == 'edit' %>
>
> -Rob
>
> Rob Biedenharn          http://agileconsultingllc.com
> r...@agileconsultingllc.com
>
> On Jun 7, 2009, at 12:22 AM, Matt W. wrote:
>
>
>
> > When I run my functional tests, they throw an error with the following
> > message:
>
> > ActionView::TemplateError: Missing template /_captcha.erb in view path
> > app/views:test/vendor/plugins/brain_buster/views/brain_busters
> >    On line #23 of app/views/contacts/_form.html.erb
>
> >        20:     <%= f.label :message %>
> >        21:     <%= f.text_area :message %>
> >        22:   
> >        23:   <%= render :partial => '/captcha' unless action_name ==
> > 'edit' %>
> >        24:   <%= f.submit "Submit" %>
> >        25: <% end %>
>
> >        app/views/contacts/_form.html.erb:23
> >        app/views/contacts/_form.html.erb:1
> >        app/views/contacts/edit.html.erb:1
> >        app/controllers/contacts_controller.rb:41:in `update'
>
> > I've checked to make sure the partial is in the right location, it is
> > in this directory:
>
> > /vendor/plugins/brain_buster/views/brain_busters/_captcha.html.erb
>
> > Any ideas as to why the test can't find the partial? It works fine
> > when I test it manually (via the browser).
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email 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 Classes

2009-06-07 Thread Frederick Cheung

On Jun 7, 10:01 pm, "J. D."  wrote:

>
> Any ideas of what I might be doing wrong?

You're not using update_all correctly - check the documentation

Fred
>
> This still has been a great day because even though I've seen tons of
> errors, I'm learning..
>
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: embed php code in rails

2009-06-07 Thread istar...@gmail.com

Conrad, I'm trying to drop Wordpress into the public folder of my
rails project, just as you said.

Did you have any trouble with the index.php files? Some error is
causing them to return blank pages.

It's frustrating, because if I manually type in 
www.satslayer/blog/wp-admin/index.php
I can see my dashboard, but
I cannot get www.satslayer/blog/index.php to work for the life of me.

When I make the wordpress site my root, it works. So something in
rails is causing a php error.

Any idea what's going on? Oh, and where are the php error log files
located?

Thank you,

Frank

On Jun 4, 3:20 pm, Conrad Taylor  wrote:
> On Thu, Jun 4, 2009 at 2:49 PM, Shuaib85  wrote:
>
> > Hi there
>
> > There are some code pieces that are available in php like currency
> > rates, and weather status, etc. Is there a way that I can use those
> > php code within rails code in the view. or is there a good rails
> > plugin for that purpose
>
> > thanks
>
> Well, if you have truly looked for similar within the Ruby gems and plugin
> repositories and cannot find an equivalent, I would recommend adding
> the functionality to existing gems/plugins or creating new ones.  From my
> experience, it was simply easier to do it this way unless the PHP and
> Ruby sides code interactions were isolated.
>
> For example, I had to integrate a Word Press blog into a Rails application.
>
> This worked great because I just dropped the blog into the public part of
> the Rails
> site and I was off to the races.  However, this didn't work so well when I
> needed
> to integrate a Rails application with a bank's billing interface that was in
> PHP.
> It simply felt wrong but the client wanted it ASAP and I ended up capturing
> the
> users input on the Rails side and submitting it to a PHP confirmation page
> for later
> submission to the bank.
>
> In short, if you can find a good isolation point between the two languages,
> I would
> use that at a means of integrating the two if you do not have time to do it
> all in
> Ruby.
>
> Good luck,
>
> -Conrad

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



[Rails] Re: Plugins not loading in production environment

2009-06-07 Thread Alastair

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



[Rails] Re: Deployment Question

2009-06-07 Thread Vivek Pandey
To host multiple applications, on the same server, you should be using the
glassfish application server (not glassfish gem).

So , let say you have a running glassfish v3 server and lets say you have
two apps in directories

~/apps1
~/apps2

You would deploy them as:


asadmin deploy ~/apps1
asadmin deploy ~/apps2

Then you can access these apps at, http://localhost:80/apps1/ and
http://localhost:80/apps2/

You also have option to package the Rails app as WAR file and deploy on
GlassFish server. See warbler doc,
http://caldersphere.rubyforge.org/warbler/.

-vivek.


On Sun, Jun 7, 2009 at 11:30 AM, JannaB  wrote:

>
> If I am using only Glassfish, and deploying to say, port 80 how
> can I handle multiple sites (multiple rails root dirs) on the same
> machine? -JannaB
>
> On Jun 5, 1:12 pm, Vivek Pandey  wrote:
> > > Vivek, you might want to create a screencast on how to deploy a Rails
> > > application
> > > using JRuby and Glassfish.  This will be helpful to others that want to
> use
> > > JRuby
> > > as well as disprove some of the negative myths attached to it.
> >
> > There are several articles/blogs/wikis entries that describe running
> Rails
> > on GlassFish server as well as glassfish gem.
> >
> > To get started see Charles Nutter blog on "Easy deployment with Glassfish
> > gem" at:
> http://blog.headius.com/2009/04/apache-jruby-rails-glassfish-easy.html
> >
> > I should have a new screen cast on Deployment of Rails/Merb/Sinatra on
> > GlassFish gem soon.
> >
> > -vivek.
> >
> >
> >
> > > -Conrad
> >
>

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



[Rails] Plugins not loading in production environment

2009-06-07 Thread Alastair

I'm moving this query out from my earlier post. This is all I can
assume that is happening here. When I run my site in production, any
methods that call plugin functionality is failing. If I have methods
in my models that call a plugin, running script/server -e production
fails to launch with an error of `method_missing': undefined method.
If I comment out all that code to at least get the server running,
when I subsequently browse to a page which calls any plugin methods
(I'm using the calendar_helper plugin, for instance), this causes the
page to generate a 500 error.

Can anyone suggest any reason why plugins would not be loading? I know
that they're there as they're all sat in the vendor directory. This
has me absolutely stumped and like I said before is literally only
occurring in production mode on my remote server. Running the site in
development works fine.

Many thanks in advance,

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



[Rails] Re: Use of Models - The Very Basics

2009-06-07 Thread Rob Biedenharn

On Jun 7, 2009, at 2:28 PM, doug wrote:
> Embarrassingly, I must admit that I have never understood models.  I
> am hoping that with this post I can clear up a basic question that
> will allow me to get a toe-hold into understanding models.  The basic
> question is this:
>
> Do we only use models with databases or do they have other uses?

Models let you encapsulate business logic.


> Models descend from ActiveRecord::Base.  That certainly gives rise to
> a notion that models are used exclusively with databases.  However, I
> have read plenty of chatter encouraging me to move code out of the
> controller and into the model.

Not always.  For example, I have a project with a SearchResult model;  
it doesn't correspond directly to a table, but it does leverage  
several other models (7, I think) that do persist data in the database.


> At the moment, I happen to be dealing with a perfect example.  In a
> user's profile I store an integer named 'flags'.  The integer is a
> decimal representation of a set of binary flags that correspond to
> various yes/no configuration selections that the user has made.  I
> have written a very short method that will accept 2 arguments, a
> user's flags integer and the weight of a specific flag.  The method
> returns true or false depending on whether the specific flag is set in
> the given flags integer. The method has absolutely nothing to do with
> a database.  The question is:  Where do I put this method? From the
> description that I have given I think that it is clear that this
> method is back-room, heavy-duty, number-crunching stuff (to use terms
> that I have seen in my reading).  So, does it go in the model?  If so,
> how do I access it from other places?
>
> Thanks very much for any input.
>
>  ... doug

So you're modeling a set of boolean flags, huh? Do you know about the  
Integer#[] method?

irb> 3.downto(0) {|i| puts "10[#{i}]==#{10[i]}"}
10[3]==1
10[2]==0
10[1]==1
10[0]==0
=> 3
irb> 10.to_s(2)
=> "1010"

The point is that this method has everything to do with the *data*. It  
is probably true that the data is persisted in the database, but this  
method would make sense even if you kept the data in an Array, yes?

Put the method into the User model. Since you didn't give enough  
specifics, I'll base an example on somewhat of a tangent since you  
mentioned "back-room".

class User
   def liberal?
 self.flags[0].nonzero?
   end
   def moderate?
 self.flags[1].nonzero?
   end
   def conservative?
 self.flags[2].nonzero?
   end
end

Instead of asking political_leaning(doug.flags, User::Moderate) you  
can just say doug.moderate? and be done. You could define constants  
for the bit/flag numbers, too.

If this doesn't help you see how to use a model, post some code and  
you might get a different style of answer.

-Rob

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



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



[Rails] Redcar (was: Rails Code Indentation)

2009-06-07 Thread Davi Vidal

Em 06-06-2009 10:34, JannaB escreveu:
> What do you use asa good RoR editor then?
>

What do you (all the list) think about Redcar?

http://redcareditor.com/

I'm using it actually and thought that I can be a very good editor.


davi

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



[Rails] Re: Error in production only: `method_missing': undefined method `has_attachment' for # (NoMethodError)

2009-06-07 Thread Alastair

Ok,

Turns out when I comment out any references to attachment_fu and
restful_authentication in my models, I can run the site in production
mode. Obviously this doesn't help as I need both those plugins
working :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Missing Template when testing with the Brain Buster Captcha partial

2009-06-07 Thread Rob Biedenharn

Take off the slash?

   <%= render :partial => 'captcha' unless action_name == 'edit' %>

-Rob

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

On Jun 7, 2009, at 12:22 AM, Matt W. wrote:

>
> When I run my functional tests, they throw an error with the following
> message:
>
> ActionView::TemplateError: Missing template /_captcha.erb in view path
> app/views:test/vendor/plugins/brain_buster/views/brain_busters
>On line #23 of app/views/contacts/_form.html.erb
>
>20: <%= f.label :message %>
>21: <%= f.text_area :message %>
>22:   
>23:   <%= render :partial => '/captcha' unless action_name ==
> 'edit' %>
>24:   <%= f.submit "Submit" %>
>25: <% end %>
>
>app/views/contacts/_form.html.erb:23
>app/views/contacts/_form.html.erb:1
>app/views/contacts/edit.html.erb:1
>app/controllers/contacts_controller.rb:41:in `update'
>
> I've checked to make sure the partial is in the right location, it is
> in this directory:
>
> /vendor/plugins/brain_buster/views/brain_busters/_captcha.html.erb
>
> Any ideas as to why the test can't find the partial? It works fine
> when I test it manually (via the browser).




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



[Rails] Re: Error in production only: `method_missing': undefined method `has_attachment' for # (NoMethodError)

2009-06-07 Thread Alastair



On Jun 7, 10:01 pm, Alastair  wrote:
> > In lieu of any better suggestions you could change it back to
> > production.rb one line at a time till you find the one causing the
> > problem.

> In lieu of any better suggestions you could change it back to
> production.rb one line at a time till you find the one causing the
> problem.

I just tried removing any references to has_attachment from my models
and ran ./script/server -e production again. That cleared those errors
but now I'm getting a new error of:

/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/
active_support/dependencies.rb:105:in `const_missing': uninitialized
constant User::Authentication (NameError)

I'm beginning to wonder if there's an issue with my rails app, in
production mode, not being able to see any plugins. Again, I can't
imagine why this would be occurring but it looks to be a possibility.

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

2009-06-07 Thread J. D.

Frederick Cheung wrote:
> 
> Does Scraper need to be an activerecord class at all ? you could pass
> to it the class whose table needs to be updated ie
> 
> def do_something(some_klass)
>   some_klass.update_all(...)
> end
> 
> or perhaps you might want to couple things a little more loosely
> 
> def do_something(some_klass)
>   some_klass.handle_scraper_data(...)
> end
> 
> Fred

Hi Fred:

Here's what I managed to do on my own (believe it or not - lol ):

My Rake Task:

Basically calling the RushingOffense class from models

desc "Parse Rushing Offenses data from ncaa.org"
task :parse_rushing_offenses => :environment do
  update_rushing = RushingOffense.new
  update_rushing.scrape
end

My Model for Rushing Offense:

Which basically I created a method for "scrape" to scrape data utilizing 
the Scraper class.  Since this model has inheritance with ActiveRecord 
it should be able to update...

class RushingOffense < ActiveRecord::Base
  def scrape
offensive_rushing = 
Scraper.new('http://web1.ncaa.org/mfb/natlRank.jsp?year=2008&rpt=IA_teamrush&site=org',
  'table', 'statstable', '//tr')
offensive_rushing.scrape_data
offensive_rushing.clean_celldata
for i in 0..offensive_rushing.numrows-1
  puts "Updating Team Name = #{offensive_rushing.rows[i][1]}."
  RushingOffense.update_all(:name => offensive_rushing.rows[i][1], 
:games => offensive_rushing.rows[i][2])
end
  end
end

Then finally, I have my scraper.rb file

#== Scraper Version 1.0
#
#*Created By:* _Elricstorm_
#
# _Special thanks to Soledad Penades for his initial parse idea which I 
worked with to create the Scraper program.
# His article is located at 
http://www.iterasi.net/openviewer.aspx?sqrlitid=wd5wiad-hkgk93aw8zidbw_
#
require 'hpricot'
require 'open-uri'

# This class is used to parse and collect data out of an html element
class Scraper #< ActiveRecord::Base
#class Scraper
  attr_accessor :url, :element_type, :clsname, :childsearch, :doc, 
:numrows, :rows
  # Define what the url is, what element type and class name we want to 
parse and open the url.
  def initialize(url, element_type, clsname, childsearch)
@url = url
@element_type = element_type
@clsname = clsname
@childsearch = childsearch
@doc = Hpricot(open(url))
@numrows = numrows
@rows = rows
  end

  # Scrape data based on the type of element, its class name, and define 
the child element that contains our data
  def scrape_data

@rows = []

(doc/"#...@element_type}.#{@clsname...@childsearch}").each do |row|
  cells = []
  (row/"td").each do |cell|

if (cell/" span.s").length > 0
  values = (cell/"span.s").inner_html.split('').collect{ 
|str|
pair = str.strip.split('=').collect{|val| val.strip}
Hash[pair[0], pair[1]]
  }

  if(values.length==1)
cells << cell.inner_text.strip
  else
cells << values.strip
  end

elsif
  cells << cell.inner_text.strip
end
  end
  @rows << cells
end
@rows.shift # Shifting removes the row containing the  table 
header elements.
@rows.delete([]) # Remove any empty rows in our array of arrays.
@numrows = @rows.length
  end

  def clean_celldata
@ro...@numrows-1][0] = 120
  end

  # Print a joined list by row to see our results
  def print_values
puts "Number of rows = #{numrows}."
for i in 0...@numrows-1
  puts @rows[i].join(', ')
end
  end
end



Now the only problem I have now is when I run the rake task, I don't get 
any errors and I see the puts for each team as it's being updated (or 
supposed to be updated).  So, it's counting each row as I expected.

I only tried to update 2 fields just for a test.. but no data is being 
listed in the database..

Any ideas of what I might be doing wrong?

This still has been a great day because even though I've seen tons of 
errors, I'm learning..

-- 
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: Error in production only: `method_missing': undefined method `has_attachment' for # (NoMethodError)

2009-06-07 Thread Alastair

> In lieu of any better suggestions you could change it back to
> production.rb one line at a time till you find the one causing the
> problem.

I've been trying that also, without much success so far. I'll keep at
it though! this is possibly the most bizarre thing ever. I'm wondering
if I'm missing a gem somewhere so am updating the remote server with
all gems installed on my development machine.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Error in production only: `method_missing': undefined method `has_attachment' for # (NoMethodError)

2009-06-07 Thread Colin Law

2009/6/7 Alastair :
>
>
>
> On Jun 7, 9:08 pm, Frederick Cheung 
> wrote:
>> On Jun 7, 8:18 pm, Alastair  wrote:
>>
>> > Hello guys,
>>
>> > I'm having a problem with running an application in production. The
>> > error I'm getting is as follows:
>>
>> Random guess: is there is a line at the bottom of environment.rb that
>> requires whatever it is that provides the has_attachment method?
>>
>
> Hi Fred,
>
> Thanks for your reply!
>
> As regards to the line in environment.rb, there isn't. The
> has_attachment, in this case, is the attachment_fu plugin. It works
> fine on my local machine in both development and production modes. It
> works on the remote server in development mode (with ./script/server)
> but is literally just failing in production mode on the remote server
> with ./script/server -e production. I completely fail to see what
> could be causing this. Now copying the development.rb file over
> production.rb on the remote server allows the application to run in
> production mode so obviously there's something in the production.rb
> environment file that is causing this error.

In lieu of any better suggestions you could change it back to
production.rb one line at a time till you find the one causing the
problem.

Colin

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



[Rails] Re: modify root URL generated by <%= link_to %>

2009-06-07 Thread Richard Schneeman

I tried setting the default_url_options in my config/environments.rb 
like this:

  config.action_controller.default_url_options = { :host => 
'example.com'}


but I get this error when i restart my server I get this error, is there 
another way to accomplish this taks?



/opt/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:530:in 
`send': undefined method `default_url_options=' for 
ActionController::Base:Class (NoMethodError)
  from 
/opt/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:530:in 
`initialize_framework_settings'
  from 
/opt/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:529:in 
`each'
  from 
/opt/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:529:in 
`initialize_framework_settings'
  from 
/opt/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:526:in 
`each'
  from 
/opt/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:526:in 
`initialize_framework_settings'
  from 
/opt/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:154:in 
`process'
  from 
/opt/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:112:in 
`send'
  from 
/opt/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:112:in 
`run'
   ... 27 levels...
  from 
/opt/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/server.rb:49
  from 
/opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in 
`gem_original_require'
  from 
/opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in 
`require'
  from script/server:3


Ruby 1.8.6
Rails 2.2.2




-- 
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: Error in production only: `method_missing': undefined method `has_attachment' for # (NoMethodError)

2009-06-07 Thread Alastair



On Jun 7, 9:08 pm, Frederick Cheung 
wrote:
> On Jun 7, 8:18 pm, Alastair  wrote:
>
> > Hello guys,
>
> > I'm having a problem with running an application in production. The
> > error I'm getting is as follows:
>
> Random guess: is there is a line at the bottom of environment.rb that
> requires whatever it is that provides the has_attachment method?
>

Hi Fred,

Thanks for your reply!

As regards to the line in environment.rb, there isn't. The
has_attachment, in this case, is the attachment_fu plugin. It works
fine on my local machine in both development and production modes. It
works on the remote server in development mode (with ./script/server)
but is literally just failing in production mode on the remote server
with ./script/server -e production. I completely fail to see what
could be causing this. Now copying the development.rb file over
production.rb on the remote server allows the application to run in
production mode so obviously there's something in the production.rb
environment file that is causing this error.

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



[Rails] Re: Need help 'observe_field' to work in Safari or Konqueror

2009-06-07 Thread Jim Burgess

That'll teach me to re-read things before I post.
The URL is: http://igsn-application.de/test/
Sorry!
-- 
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] Need help 'observe_field' to work in Safari or Konqueror

2009-06-07 Thread Jim Burgess

Hi,

I have a form with two drop down menus.
Depending on what the user selects in the first, the second should be
populated accordingly.

Here is the code I am using to do this.

View (test.html.erb):
<% form_for :applicant, :url=> {:action => "index"} do |f| %>

<%= f.label :topic_1 %>
<%= f.select :topic_1, ["a", "b", "c", "d", "e", "f"], :include_blank =>
true %>

<%= observe_field "applicant_topic_1", :update => "applicant_member_1",
:with => "topic_1", :url => { :controller => "form", :action =>
"get_members_1" } %>

<%= f.label :member_1 %>
<%= f.select :member_1, ["Please select topic 1 first"] %>

---
Controller:
def get_members_1
@members_1 = Member.find_all_by_topic params[:topic_1]
end

---
View (get_members_1.html.erb):
This is no. 1
(I have shortened this for sake of simplicity. Normally a lookup of all
members would take place here)

As you can see, when the user enters something in 'topic_1' the
observe_field helper calls the method 'get_members_1' in the controller,
and updates the field 'member_1' dynamically.

Here is this example in action: http://localhost:3000/test

My problem is that this works fine in FF, IE, Chrome and Opera, but it
doesn't work at all in Konqueror.

I have Googled the problem and come up empty handed.

This is the java script that the helper generates:



Can anybody point me in the right direction to sort this out?
I am relatively ok at ruby / rails, but a beginner regarding java script
/ ajax.

I also had a look on the rails doc page regarding observe_field, but I
cannot see what I am doing wrong.

I would be grateful for any help.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: ActiveRecord Classes

2009-06-07 Thread Frederick Cheung



On Jun 7, 8:30 pm, "J. D."  wrote:
> I think I found my own answer to the last question - a single class
> cannot inherit across multiple classes. :(
>

Does Scraper need to be an activerecord class at all ? you could pass
to it the class whose table needs to be updated ie

def do_something(some_klass)
  some_klass.update_all(...)
end

or perhaps you might want to couple things a little more loosely

def do_something(some_klass)
  some_klass.handle_scraper_data(...)
end

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



[Rails] Re: Error in production only: `method_missing': undefined method `has_attachment' for # (NoMethodError)

2009-06-07 Thread Frederick Cheung



On Jun 7, 8:18 pm, Alastair  wrote:
> Hello guys,
>
> I'm having a problem with running an application in production. The
> error I'm getting is as follows:

Random guess: is there is a line at the bottom of environment.rb that
requires whatever it is that provides the has_attachment method?

Fred
>
> /home/www/bandera/releases/20090607191259/vendor/rails/activerecord/
> lib/active_record/base.rb:1964:in `method_missing': undefined method
> `has_attachment' for # (NoMethodError)
>         from /home/www/bandera/releases/20090607191259/app/models/document.rb:
> 8
>         from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
> 31:in `gem_original_require'
>         from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
> 31:in `require'
>         from /home/www/bandera/releases/20090607191259/vendor/rails/
> activesupport/lib/active_support/dependencies.rb:158:in `require'
>         from /home/www/bandera/releases/20090607191259/vendor/rails/
> activesupport/lib/active_support/dependencies.rb:265:in
> `require_or_load'
>         from /home/www/bandera/releases/20090607191259/vendor/rails/
> activesupport/lib/active_support/dependencies.rb:224:in `depend_on'
>         from /home/www/bandera/releases/20090607191259/vendor/rails/
> activesupport/lib/active_support/dependencies.rb:136:in
> `require_dependency'
>         from ./script/../config/../vendor/rails/railties/lib/initializer.rb:
> 393:in `load_application_classes'
>          ... 13 levels...
>         from /home/www/bandera/releases/20090607191259/vendor/rails/railties/
> lib/commands/server.rb:84
>         from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
> 31:in `gem_original_require'
>         from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
> 31:in `require'
>         from ./script/server:3
>
> This error occurs when I run './script/server -e production'. If I run
> './script/server' immediately afterwards, the site runs fine without
> issue. I can't see for the life of me what could be causing this
> problem and would appreciate any help!
>
> Regards,
>
> Alastair
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email 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 Code Indentation

2009-06-07 Thread Scott Tamosunas

RubyMine has an excellent code formatter. Just write your code and Cmd-
Option-L.

Scott

On Jun 7, 9:07 am, prabesh shrestha  wrote:
> Netbeans is good for that.
> On Jun 7, 8:04 am, Mohit Sindhwani  wrote:
>
> > JannaB wrote:
> > > What do you use asa good RoR editor then?
>
> > NetBeans indents very well.
> > Cheers,
> > Mohit.
> > 6/7/2009 | 11:03 AM.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Error in production only: `method_missing': undefined method `has_attachment' for # (NoMethodError)

2009-06-07 Thread Alastair

Hello guys,

I'm having a problem with running an application in production. The
error I'm getting is as follows:

/home/www/bandera/releases/20090607191259/vendor/rails/activerecord/
lib/active_record/base.rb:1964:in `method_missing': undefined method
`has_attachment' for # (NoMethodError)
from /home/www/bandera/releases/20090607191259/app/models/document.rb:
8
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
31:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
31:in `require'
from /home/www/bandera/releases/20090607191259/vendor/rails/
activesupport/lib/active_support/dependencies.rb:158:in `require'
from /home/www/bandera/releases/20090607191259/vendor/rails/
activesupport/lib/active_support/dependencies.rb:265:in
`require_or_load'
from /home/www/bandera/releases/20090607191259/vendor/rails/
activesupport/lib/active_support/dependencies.rb:224:in `depend_on'
from /home/www/bandera/releases/20090607191259/vendor/rails/
activesupport/lib/active_support/dependencies.rb:136:in
`require_dependency'
from ./script/../config/../vendor/rails/railties/lib/initializer.rb:
393:in `load_application_classes'
 ... 13 levels...
from /home/www/bandera/releases/20090607191259/vendor/rails/railties/
lib/commands/server.rb:84
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
31:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
31:in `require'
from ./script/server:3

This error occurs when I run './script/server -e production'. If I run
'./script/server' immediately afterwards, the site runs fine without
issue. I can't see for the life of me what could be causing this
problem and would appreciate any help!

Regards,

Alastair

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

2009-06-07 Thread J. D.

I think I found my own answer to the last question - a single class 
cannot inherit across multiple classes. :(

-- 
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 Classes

2009-06-07 Thread J. D.

Another thing I considered is inheritance.

If I do

class Scraper < RushingOffenses then the RushingOffenses class located 
in the rushing_offense.rb model would inherit it.  Then I could possibly 
put the following in my rake task:

offensive_rushing = RushingOffense::Scraper.new

However, I would want Scraper to be a part of every statistical class I 
create.  So, it would have to be a member of:

RushingOffense
PassingOffense
ScoringOffense
etc...

How would I force inheritance across multiple classes?
-- 
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: Use of Models - The Very Basics

2009-06-07 Thread Christoph Jasinski
I'm not a Rails pro, but I would like to make the following comments:
A model

   - represents your Data you deal with, like students/products... which you
   save in a database!
   - should include operations/methods which exclusively deal with the
   object/data, like setter/getter moethds and/or computing specific things
   like an access/activation code

The convention is, as far as I now, to keep the controller clean and light.
But in certain scenarios it make sense to keep some functionality in the
controller. However in you case I would definitely put it into the model.
"The method has absolutely nothing to do with a database", sure but it has a
lot to do with the data/objects you store there. You call that special
method on a specific object as I understand you point. You can do something
like
user.your_method or user.your_method(variavble1,variable2) where you define
your_method in the model file in rails.


Cheers & good luck,

Chris

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

2009-06-07 Thread J. D.

To add another thought to the mix:

The only reason why I'm defining a rake task is that eventually the rake 
task will be managed by a cron job for populating the data for my 
database on a weekly basis (say every sunday night).

The main bulk of the remainder of my project will just be dealing with 
controllers and views for how the site is listed..

So, the population of data from an external source is the big issue 
right now.

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

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



[Rails] Re: ActiveRecord Classes

2009-06-07 Thread J. D.

To expand upon the issue:

There are approximately 37 different categories for College Football 
that house statistics.  I will be parsing 37 different URLs to pull and 
retrieve data that will be pushed to my database.  The Scraper class is 
the tool for doing that.

Each call within my rake task is going to call specific URLs using the 
methods located in the Scraper class but will update to specific table 
names.

Example:

rushing_offense.rb ---> connects to the rushing_offenses table
passing_offense.rb ---> connects to the passing_offenses table
scoring_offense.rb ---> connects to the scoring_offenses table

Call to scraper.rb to parse data from a rushing offense URL
Call to scraper.rb to update data to rushing_offenses table
Call to scraper.rb to parse data from a passing offense URL
Call to scraper.rb to update data to passing_offenses table
Call to scraper.rb to parse data from a scoring offense URl
Call to scraper.rb to update data to scoring_offenses table
etc. etc.
-- for 37 different categories
-- 
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: Deployment Question

2009-06-07 Thread JannaB

If I am using only Glassfish, and deploying to say, port 80 how
can I handle multiple sites (multiple rails root dirs) on the same
machine? -JannaB

On Jun 5, 1:12 pm, Vivek Pandey  wrote:
> > Vivek, you might want to create a screencast on how to deploy a Rails
> > application
> > using JRuby and Glassfish.  This will be helpful to others that want to use
> > JRuby
> > as well as disprove some of the negative myths attached to it.
>
> There are several articles/blogs/wikis entries that describe running Rails
> on GlassFish server as well as glassfish gem.
>
> To get started see Charles Nutter blog on "Easy deployment with Glassfish
> gem" at:http://blog.headius.com/2009/04/apache-jruby-rails-glassfish-easy.html
>
> I should have a new screen cast on Deployment of Rails/Merb/Sinatra on
> GlassFish gem soon.
>
> -vivek.
>
>
>
> > -Conrad
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: namespaced application layout?

2009-06-07 Thread elliottg

Thanks Maurício.

That worked nicely.

On Jun 5, 11:02 pm, Maurício Linhares 
wrote:
> Create a basic admin controller, like this:
>
> class Admin::BaseController < ApplicationController
>     layout :admin
> end
>
> Then make all admin controllers inherit from it. And also create an
> layouts/admin.html.erb file ;)
>
> -
> Maurício Linhareshttp://alinhavado.wordpress.com/(pt-br) 
> |http://codeshooter.wordpress.com/(en)
>
>
>
> On Fri, Jun 5, 2009 at 8:52 PM, elliottg wrote:
>
> > I have an admin namespace in my app. I would like to have a layout
> > that would work like app/layouts/application.html.erb, but instead off
> > affecting the entire app it would only affect all the views inside of
> > Admin::*
>
> > How would this be done?
>
> > Thanks,
> > Elliott
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Use of Models - The Very Basics

2009-06-07 Thread doug

Embarrassingly, I must admit that I have never understood models.  I
am hoping that with this post I can clear up a basic question that
will allow me to get a toe-hold into understanding models.  The basic
question is this:

Do we only use models with databases or do they have other uses?

Models descend from ActiveRecord::Base.  That certainly gives rise to
a notion that models are used exclusively with databases.  However, I
have read plenty of chatter encouraging me to move code out of the
controller and into the model.

At the moment, I happen to be dealing with a perfect example.  In a
user's profile I store an integer named 'flags'.  The integer is a
decimal representation of a set of binary flags that correspond to
various yes/no configuration selections that the user has made.  I
have written a very short method that will accept 2 arguments, a
user's flags integer and the weight of a specific flag.  The method
returns true or false depending on whether the specific flag is set in
the given flags integer. The method has absolutely nothing to do with
a database.  The question is:  Where do I put this method? From the
description that I have given I think that it is clear that this
method is back-room, heavy-duty, number-crunching stuff (to use terms
that I have seen in my reading).  So, does it go in the model?  If so,
how do I access it from other places?

Thanks very much for any input.

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

2009-06-07 Thread J. D.

I'm having a little trouble with understanding how to work out the
schematic for some of my classes using ActiveRecord when a file is in my
lib directory:

Brief example:

Here's the outline of the files in use:

app
controllers
application_controller.rb
rushing_offenses_controller.rb
models
rushing_offense.rb
lib
scraper.rb
tasks
scraper.rake

The rushing_offense.rb file contains:

class RushingOffense < ActiveRecord::Base
end

The scraper.rb file contains:

class Scraper < ActiveRecord::Base
# METHOD that define which URL to parse
# METHOD that parses the data into an instanced variable called @rows
# METHOD that should be updating my database table called
"rushing_offenses"
# Update Rushing Offense
  def update_rushing_offense
for i in 0...@numrows-1
  update_all(:name => @rows[i][0], :games => @rows[i][1])
  puts "Updating Team Name = #...@rows[i][0]}."
end
  end
end

The scraper.rake file contains:

desc "This task will parse data from ncaa.org and upload the data to our
db"
task :scraper => :environment do
  offensive_rushing =
Scraper.new('http://web1.ncaa.org/mfb/natlRank.jsp?year=2008&rpt=IA_teamrush&site=org',
'table', 'statstable', '//tr')
  offensive_rushing.scrape_data
  offensive_rushing.clean_celldata
  offensive_rushing.print_values
  offensive_rushing.update_rushing_offense # the call to the method
above
end

Now if I run the rake file what is going to happen is I'm going to get
an error stating:

Table 'project_development.scrapers' doesn't exist:

I believe I understand why that's happening but I'm not sure how to fix
it from a long term perspective.  Here's why...

The class Scraper is pushed into the ActiveRecord::Base so it believes
the class is the pluralized name of the table Scrapers.  I then thought
well maybe I need to put the code in the rushing_offenses_controller.rb
file in that class but here's the issue I'm having:

The Scraper class should be a class that I can call with other classes
to do repetitive tasks on many different URLs.  I've setup the class to
do that with the methods being able to retrieve different URLs.

So, I want my Scraper class to just act like a utility class to be used
by other classes to parse data, and upload it to the correct database
table.  If I place the scraper class inside the
rushing_offenses_controller file then I'm not following DRY principles.
I don't want to have to repeat code over and over.

Any ideas on how I can rectify this issue I'm having?
-- 
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: Rails way to do long running tasks

2009-06-07 Thread Bharat

Two pointers from personal experience:

1.  Don't use backgroundrb for asynchronous processing
2.  Do use javan-whenever to automate your cron jobs (available on
Github)

Bharat

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



[Rails] Re: XML::LibXML::Reader

2009-06-07 Thread lecielbleu

ok Jeff i solved problem , using "doc" was a bad mistake :) thanks for
your support ,here is the last codes

while reader.read
case reader.name
when "Brand_name"
name_from_xml = reader.read_string
Brand.create( :name => name_from_xml )
end
end



now i have to solve another problem :) do you know how can i get a
brand_name using filter brand_id

while reader.read
case reader.read_string
when 55
   ---magic line i couldnt find :)
--
end
end

magic line must be get brand_name value "Dell" using "55"

Sample xml code ===>>  55Dell


On Jun 4, 9:36 pm, "Jeffrey L. Taylor"  wrote:
> I'm afraid I don't understand what you are trying to do here.  'doc' isn't in
> the example below.  So how the loop would change its value, I am unclear.  It
> seems like you are saying a loop with an unchanging condition runs forever.
> Yes, it does.
>
> Did you intend to do this:
>
> while reader.read
>   puts reader.read_string
> end
>
> HTH
>   Jeff
>
> Quoting lecielbleu :
>
>
>
> > i tried also
> > while doc == true
> > while doc = 1
> > while doc
>
> > results dont change
>
> > On Jun 4, 12:51 pm, lecielbleu  wrote:
> > > i guess problem is while reader line because when i run basic code
> > > below :
>
> > > while doc == true
> > >                         puts reader.read_string
> > >                 end
>
> > > strings never stops in the command line , it turns infinite loop.
>
> > > On Jun 4, 12:48 am, "Jeffrey L. Taylor"  wrote:
>
> > > > There are no  header tags.  I have no idea how libXML will behave. 
> > > >  It
> > > > isn't very tolerant of invalid input.  Try adding the puts statements 
> > > > I've
> > > > inserted below to find out how far it is getting.
>
> > > > Quoting lecielbleu :
>
> > > > > my xml data seems like that : 2 > > > > Brand_id>HP
> > > > > and here is my codes
>
> > > > > def xml_testing
> > > > >            require'xml'
> > > > >            reader = XML::Reader.file('c:/brands.xml')
>
> > > > >            stack = []
> > > > >            while reader
> > > > >              case reader.node_type
> > > > >              when XML::Reader::TYPE_ELEMENT
> > > > >                # opening tag
> > > > >                stack << reader.name
>
> > > >                     puts "BEGIN #{stack.join('/')}">                
> > > > stack.pop if reader.empty_element?
>
> > > >                     puts "END #{stack.join('/')}"  if 
> > > > reader.empty_element?>              when XML::Reader::TYPE_TEXT, 
> > > > XML::Reader::TYPE_CDATA
> > > > >                path = stack.join('/')
> > > > >                case path
> > > > >                when 'Brands/Brand/Brand_name'
> > > > >                  puts reader.value         # simple content
> > > > >               when XML::Reader::TYPE_END_ELEMENT
> > > > >                # closing tag
>
> > > >                     puts "END #{stack.join('/')}"
>
> > > > >                stack.pop
> > > > >              end
> > > > >      end
> > > > >      end
>
> > > > >            flash.now[:message]="brands read"
> > > > >    end
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to access parent property

2009-06-07 Thread Developer In London
That Works! Thanks!

2009/6/7 Marnen Laibow-Koser 

>
> developerinlondon wrote:
> > Hi,
> >
> > I am having difficulties accessing parent properties/attributes from
> > the child. Anyone could shed some lights onto this?
> >
> > Heres a sample code:
> [...]
>
> Your sample code will not do the job.  All you need is
>
> class Parent > ActiveRecord::Base
>  has_many :children
> end
>
> class Child > ActiveRecord::Base
>  belongs_to :parent
> end
>
> ...and parent.children and child.parent will work as you'd like.
> @connector is unnecessary.
>
> Check the docs for Associations; Rails makes this ridiculously simple.
>
> Best,
> --
> Marnen Laibow-Koser
> http://www.marnen.org
> mar...@marnen.org
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>


-- 
cashflowclublondon.co.uk

  ("`-''-/").___..--''"`-._
   `6_ 6  )   `-.  ( ).`-.__.`)
   (_Y_.)'  ._   )  `._ `. ``-..-'
 _..`--'_..-_/  /--'_.' ,'
(il),-''  (li),'  ((!.-'
.

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



[Rails] modify root URL generated by <%= link_to %>

2009-06-07 Thread Richard Schneeman

Is there a way to manually specify the root url that a <%= link_to %>
generates? So i can make an auto generated url that used to go to
mywebsite.myhost.com/comments be go to example.com/comments ?


The reason, if you're wondering is that I have hosting at a site and my
domain forwarded and masked through go-daddy. This means when you go to
example.com you are seeing content on mywebsite.myhost.com but the url
shows up as example.com. The problem comes when you click on a link for
lets say comments, for whatever reason instead of showing
example.com/comments in the url it just shows example.com.  If you type
example.com/comments directly into the address bar though, everything
works great  you get the content you expect and the url you expect. So
how can i make my <%= link_to %>'s use example.com as the base url
instead of mywebsite.myhost.com???
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: why do restful_authentication generated rspec tests fail?

2009-06-07 Thread Jonathan

Many thanks for the explanation. Just what I needed to know.


On Jun 8, 2:00 am, Maurício Linhares 
wrote:
> They break 'cos they rely in a old Rspec behaviour for matching routes.
>
> The best you can do is just remove all restful_auth specs and cucumber
> scenarios (they're HORRIBLE, btw, you probably won't understand
> anything anyway and any change is going to be a PITA) and just write
> your own specs and Cucumber scenarios. Way more simpler than fixing
> and keeping all those specs in your project.
>
> But, if you're in to "fix' those specs, the problem is that routes
> that are not expected to be used as GET requests should be matched
> with this:
>
> { :path => '/users', :method => :post}
>
> Instead of just "/users".
>
> -
> Maurício Linhareshttp://alinhavado.wordpress.com/(pt-br) 
> |http://codeshooter.wordpress.com/(en)
>
>
>
> On Sun, Jun 7, 2009 at 1:51 PM, Jonathan wrote:
>
> > Been searching online for an answer to this without success - also
> > been digging through the documentation but I'm still very new to
> > rails.
>
> > I started a brand new app (rails 2.3.2), then the first thing I did
> > was install restful_authentication with the --rspec and --
> > include_activation options, then went through and followed the
> > directions for post install as detailed in the plugin documentation.
> > Performed a migration, then ran the rspec tests generated by the
> > plugin. The tests failed with 6 errors, which I wasn't expecting
> > because I haven't personally written a line of code yet, just used the
> > rails and restful_authentication generated code. Has anyone else run
> > into this?
>
> > Thanks in advance~
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to access parent property

2009-06-07 Thread Marnen Laibow-Koser

developerinlondon wrote:
> Hi,
> 
> I am having difficulties accessing parent properties/attributes from
> the child. Anyone could shed some lights onto this?
> 
> Heres a sample code:
[...]

Your sample code will not do the job.  All you need is

class Parent > ActiveRecord::Base
  has_many :children
end

class Child > ActiveRecord::Base
  belongs_to :parent
end

...and parent.children and child.parent will work as you'd like. 
@connector is unnecessary.

Check the docs for Associations; Rails makes this ridiculously simple.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Advice for quick fire DB replication with Rails

2009-06-07 Thread yitzhakbg

Thanks

On Jun 7, 7:03 pm, Roderick van Domburg  wrote:
> Yitzhak Bar Geva wrote:
> > Let's say we had to go it on our own, could you or anyone else
> > recommend the quicky recipe I'm seeking?
>
> Doing a Google search for "mysql heartbeat" should yield some candidate
> results.
> Generally:
>
>  1. Set up a master/master MySQL configuration on two nodes as usual.
> Let one node use even numbers for autoincrements, the other one odd
> numbers.
>
>  2. Set up Heartbeat to float a single IP address between the two nodes.
>
>  3. Have the Rails application connect to the floating IP address.
>
> --
> Roderick van Domburghttp://en.railscluster.nl
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Rails way to do long running tasks

2009-06-07 Thread Matt Jones

For emails, the simplest way is to set up a local MTA (postfix, for
instance) and send the mail to that. The MTA takes care of the hard
part delivering the mail as needed.

For more general things, there are some gems that let you set up cron-
like tasks, or you can just call a rake task from plain old cron.

--Matt Jones


On Jun 6, 8:23 pm, Chris  wrote:
> Hello Rails community,
>
>   I would like to get some advices - I am writing a web application
> that will be sending some emails and execute other long running tasks.
>
>   Some of these tasks may take some time and I do not want the user
> experience to be impacted. I would appreciate any pointers on advices
> on these areas:
>
>    *   how to send emails without making the user wait
>    *   how to execute long running tasks
>    *   The best way to do periodic cron jobs in Rails
>
> Thank you for your help in advance.
>
> Chris
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: why do restful_authentication generated rspec tests fail?

2009-06-07 Thread Maurício Linhares

They break 'cos they rely in a old Rspec behaviour for matching routes.

The best you can do is just remove all restful_auth specs and cucumber
scenarios (they're HORRIBLE, btw, you probably won't understand
anything anyway and any change is going to be a PITA) and just write
your own specs and Cucumber scenarios. Way more simpler than fixing
and keeping all those specs in your project.

But, if you're in to "fix' those specs, the problem is that routes
that are not expected to be used as GET requests should be matched
with this:

{ :path => '/users', :method => :post}

Instead of just "/users".

-
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) |
http://codeshooter.wordpress.com/ (en)



On Sun, Jun 7, 2009 at 1:51 PM, Jonathan wrote:
>
> Been searching online for an answer to this without success - also
> been digging through the documentation but I'm still very new to
> rails.
>
> I started a brand new app (rails 2.3.2), then the first thing I did
> was install restful_authentication with the --rspec and --
> include_activation options, then went through and followed the
> directions for post install as detailed in the plugin documentation.
> Performed a migration, then ran the rspec tests generated by the
> plugin. The tests failed with 6 errors, which I wasn't expecting
> because I haven't personally written a line of code yet, just used the
> rails and restful_authentication generated code. Has anyone else run
> into this?
>
> Thanks in advance~
> >
>

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



[Rails] why do restful_authentication generated rspec tests fail?

2009-06-07 Thread Jonathan

Been searching online for an answer to this without success - also
been digging through the documentation but I'm still very new to
rails.

I started a brand new app (rails 2.3.2), then the first thing I did
was install restful_authentication with the --rspec and --
include_activation options, then went through and followed the
directions for post install as detailed in the plugin documentation.
Performed a migration, then ran the rspec tests generated by the
plugin. The tests failed with 6 errors, which I wasn't expecting
because I haven't personally written a line of code yet, just used the
rails and restful_authentication generated code. Has anyone else run
into this?

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



[Rails] Re: Ruby w/ Apache mod_proxy

2009-06-07 Thread Rick DeNatale

On Sun, Jun 7, 2009 at 9:37 AM, JannaB wrote:

> So I am trying to mod_proxy the site to the url with port 81 that I
> know works. Here is how I have the VirtualHost in my httpd.conf file
> set up:
>
> 
>    ServerName gg
...
> 
>

...
> whenever I go to hit http://127.0.0.1/gg I get a 404 not found error.
> I am certain my document root is correct. Can you fellows here who
> have done this tell me what I am missing? Thanks, Janna B.

The servername of http://127.0.0.1/gg is not gg but 127.0.0.1 so I'm
pretty sure that the virtualhost directive isn't having any effect for
the request.

I'd try adding an entry in /etc/hosts to map gg to 127.0.0.1  and then
point the browser at

http://gg

and see what happens

-- 
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

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



[Rails] Re: Calendar Plugin

2009-06-07 Thread prabesh shrestha

Thanks bjreath and Wlater for your suggestions.I was completing some
other tasks.Now I am using calendar_helper.I am going through it's
code which is pretty small than I had guessed.If I need any help I
will surely post back.
Thanks again.

On May 29, 10:01 am, Walter McGinnis 
wrote:
> http://github.com/search?type=Repositories&language=rb&q=calendar&rep...
> A lot of calendar plugins aren't going to be ready for translation if you
> decide to go the the i18n route.  Something to keep in mind when choosing.
>
> Cheers,
> Walter
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email 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 Code Indentation

2009-06-07 Thread prabesh shrestha


Netbeans is good for that.
On Jun 7, 8:04 am, Mohit Sindhwani  wrote:
> JannaB wrote:
> > What do you use asa good RoR editor then?
>
> NetBeans indents very well.
> Cheers,
> Mohit.
> 6/7/2009 | 11:03 AM.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Advice for quick fire DB replication with Rails

2009-06-07 Thread Roderick van Domburg

Yitzhak Bar Geva wrote:
> Let's say we had to go it on our own, could you or anyone else
> recommend the quicky recipe I'm seeking?

Doing a Google search for "mysql heartbeat" should yield some candidate 
results.
Generally:

 1. Set up a master/master MySQL configuration on two nodes as usual. 
Let one node use even numbers for autoincrements, the other one odd 
numbers.

 2. Set up Heartbeat to float a single IP address between the two nodes.

 3. Have the Rails application connect to the floating IP address.

--
Roderick van Domburg
http://en.railscluster.nl
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: How do i model this in Rails? (put down java equivalent design)

2009-06-07 Thread AGoofin

Does seem to be a bit of repetition in your description but it seems
straightforward.

You have a Module which has an Entity_type column

Each Module has many Chapters where Chapters has a column named
module_id.

Each Chapter has many Activities with similar foreign key constraints
or
You have one Activities table, in which case you don't specify a
relationship.

Once you set up the has_many and belongs_to pairs, Rails provides the
methods to interact with the data.

Checkout some ActiveRecord tutorials like this screencast -
http://www.railsenvy.com/2007/8/8/activerecord-tutorial

On Jun 6, 10:29 pm, Ritvvij  wrote:
> Hello guys,
>
> Need help!! Finding it hard to model the 'model' :P within the given
> rails associations.
>
> In java terms, my requirements are...
>
> There are 3 entities - module, chapter and activity.
>
> Chapter entity is a specilization of Module entity (inheritence)
> Activity entity is a specialization of Module entity (inheritence)
> And the tables would have looked like:
> 1. Module table = Module_Id, Entity_type, 
> 2. Chapter = Chapter_id, .
> 3. Activity = Activity_id, ..
>
> Hence, if I create a chapter then the tables would be populated as:
> Module table = Module_Id, Entity_type,  = values ( 100,
> chapter ,  )
> Chapter table = chapter_id, . = values ( 100,  )
> Basically, the ids of chapter and module would be same and module
> table would store the type.
>
> Now, if I create a activity then the tables would be populated as:
> Module table = Module_Id, Entity_type,  = values ( 101,
> activity ,  )
> Activity table = activity_id, . = values ( 100,  )
> Basically, the ids of activity and module would be same and module
> table would store the type.
>
> Can you please guide me how I can model it similarly in rails 2.3.2?
>
> Thanks in advance
> Ritvvij Parrilkh
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: GeoLocation for any Cell Phone with GPS

2009-06-07 Thread AGoofin

A quick Google search turned up a few possibilities:

(ruby geolocation)
http://earthcode.com/blog/2007/02/geokit_map_plugin.html

There are a few ways though to take a lat/long and transpose them to a
map or do other fun things with them.  Try looking at Google maps as
well.

On Jun 6, 1:47 pm, flaubert  wrote:
> Hi all,
>
> I'm having the following problem: I need a user using any device of
> any GPS is advised that at a certain place. I search on the net with
> articles on Global Positioning RubyonRails, but without success.
>
> Can anyone help me?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Ruby w/ Apache mod_proxy

2009-06-07 Thread JannaB

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



[Rails] Iconv::InvalidEncoding (""ISO-8859-1"", "UTF-8")

2009-06-07 Thread Ariel Sch

Hi,


I'm having the error: Iconv::InvalidEncoding: invalid encoding
(""ISO-8859-1"", "UTF-8") when trying to post via Mechanize.

It used to work just fine, but the error appeared after (I think)
upgrading to Rails 2.3.2, Ruby 1.8.7, Mechanize 0.9.2 (I upgraded a
while ago and only now noticed the problem).

What does it mean? Is there any way to disable/bypass the error?
Any help would be much appreciated!

Thanks a lot,
Ariel
-- 
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 Tasks

2009-06-07 Thread J. D.

Thanks - I understand that part now!

I put scraper.rb in my Libs folder
I put scraper.rake in my libs/tasks

I took the end portion of scraper.rb and removed it placing it in my 
rake file:

desc "This task will parse data from ncaa.org and upload the data to our 
db"
task :scraper => :environment do
  # In our search we are supplying the website url to parse, the type of 
element (ex: table), the class name of that element
  # and the child element that contains the data we wish to retrieve.
  offensive_rushing = 
Scraper.new('http://web1.ncaa.org/mfb/natlRank.jsp?year=2008&rpt=IA_teamrush&site=org',
'table', 'statstable', '//tr')
  offensive_rushing.scrape_data
  offensive_rushing.clean_celldata
  offensive_rushing.print_values
end

And it did a print out when I called the rake..  So, now I'll have to 
test this with the database and see how it works...

Thanks a ton (I understand it now)..

The part that was => environment do was telling my rake task to make 
sure that the environment was fully loaded before running it.

So, if I wanted to run another rake task in the same rake file and I 
wanted to make sure the first was done, I'd do something like:

task: next_task => :scraper do
  # code
end

which would make it run only after the scraper task had finished..



-- 
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 Tasks

2009-06-07 Thread J. D.

Frederick Cheung wrote:
> On Jun 7, 1:40�pm, "J. D."  wrote:
>> include anything to call that .rb file? �I'm sorry if I am
>> misunderstanding this portion of the mechanics.
>>
>>
> Because your task depends on :environment Rails is loaded, in
> particular its dependency management is loaded so it will find your
> Scraper class as long as it's in scraper.rb somewhere on its search
> path. Don't take my word for it though, try it!
> 
> Fred

Thanks,

I'll test a couple of generic variables and puts...
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: How to access parent property

2009-06-07 Thread Developer In London
No I need to have it so that Child has one parent.

I managed to get a reference to the parent by using the ObjectSpace. But its
almost a hack then a nice way of doing it.

2009/6/7 Conrad Taylor 

>
> Hi, when I saw your models, I was thinking that you should have the
> following relationships:
>
> Parent has many children
>
> Child has many parents
>
> Thus, you should have the following database tables:  children and
> parents.  By doing this, this becomes a many to many relationship.
>
> Good luck,
>
> -Conrad
>
> Sent from my iPhone
>
> On Jun 7, 2009, at 1:35 AM, developerinlondon 
> wrote:
>
> >
> > Hi,
> >
> > I am having difficulties accessing parent properties/attributes from
> > the child. Anyone could shed some lights onto this?
> >
> > Heres a sample code:
> >
> > class Parent < ActiveRecord::Base
> >  :has_many => :childs
> >  @connector
> >  def before_save
> >@connector = 'some connector object'
> >0..9.do |count|
> >  self.childs << Child.new
> >  self.childs[count].connector = @connector
> >end
> >  end
> > end
> >
> > class Child < ActiveRecord::Base
> >  :belongs_to => :parent
> >  @connector
> >   def before_save
> >  # code goes here to access @connector
> >   end
> > end
> >
> > The above is just a recreation of what I am looking to do. So
> > basically I want to be able to access objects like the connector from
> > the child, or even the parent itself by something like
> > self.parent.attributes.
> >
> > Any ideas?
> >
> > thanks,
> >
> > nayeem
> >
> > >
>
> >
>


-- 
cashflowclublondon.co.uk

  ("`-''-/").___..--''"`-._
   `6_ 6  )   `-.  ( ).`-.__.`)
   (_Y_.)'  ._   )  `._ `. ``-..-'
 _..`--'_..-_/  /--'_.' ,'
(il),-''  (li),'  ((!.-'
.

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



[Rails] Subject: [ANN] ri_cal 0.6.1 Released

2009-06-07 Thread Rick DeNatale

ri_cal version 0.6.1 has been released!

This version has no functional changes from 0.6.0, it fixes an obscure
problem with the spec:with_activesupport rake task, found by Paul
Scott-Murphy

* 
* 

A new Ruby implementation of RFC2445 iCalendar.

The existing Ruby iCalendar libraries (e.g. icalendar, vpim) provide
for parsing and generating icalendar files,
but do not support important things like enumerating occurrences of
repeating events.

This is a clean-slate implementation of RFC2445.

A Google group for discussion of this library has been set up
http://groups.google.com/group/rical_gem

Changes:

### 0.6.1 - 6 June 2009
 * Fixed problem with file which loads activesupport for the rake
spec:with_activesupport task, it now
   requires >=2.2 instead of <=2.2 - Thanks to Paul Scott-Murphy for
finding this.
### 0.6.0 - 5 June 2009
 Time for a minor version bump.
 * Improved overall enumeration performance bypassing most of the
effects of the poor performance of Ruby's DateTime class.
 * Added a framework for performance monitoring during development.
   - New performance directory with subdirs for code to be monitored
for performance (subjects)
   - New script files:
script/benchmark_subject runs a ruby benchmark on one
performance subject
script/profile_subject runs ruby-prof for a subject and puts a
kcachegrind compatible calltree in the performance_data directory.
   - New rake tasks:
performance:benchmark runs benchmarks against all subjects in
the performance directory and produces a consolidated output file in
performance_data/benchmarks.out
performance:profile runs script/profile_subject against all
subjects in the performance directory.
### 0.5.3 - 1 June, 2009
 * Improved performance of time zone enumeration, TimeZonePeriod now
caches occurrences
 * Added a profiling directory which contains ruby programs which
benchmark and/or profile performance
### 0.5.2
 * Fixed http://rick_denatale.lighthouseapp.com/projects/30941/tickets/11
   Export folding is not UTF-8 Safe
### 0.5.1
 * Fixed README to acknowledge release on RubyForge
### 0.5.0 rubyforge release candidate Tue May 26 10:26:43 2009 -0400
 * Added OccurrenceEnumerator#zulu_occurrence_range
### 0.0.11 Sat May 23 18:24:57 2009 -0400
 * Fixed http://rick_denatale.lighthouseapp.com/projects/30941/tickets/5
 * Fixed http://rick_denatale.lighthouseapp.com/projects/30941/tickets/9
### 0.0.10
 * Fixed http://rick_denatale.lighthouseapp.com/projects/30941/tickets/8
### 0.0.9
  * Fixed http://rick_denatale.lighthouseapp.com/projects/30941/tickets/4
Missing comparison methods in PropertyValue::Date
  * Fixed http://rick_denatale.lighthouseapp.com/projects/30941/tickets/6
Type of dtstart and dtend (DATE or DATETIME) now preserved on enumeration
### 0.0.8
  * Fixed http://rick_denatale.lighthouseapp.com/projects/30941-ri_cal/tickets/1
EXDATE and RDATE now pick up the timezone from DateTime, Time, and
TimeWithZone values
  * Fixed http://rick_denatale.lighthouseapp.com/projects/30941/tickets/2
Missing arithmetic methods in PropertyValue::Date
  * Fixed http://rick_denatale.lighthouseapp.com/projects/30941/tickets/3
   Components with no recurrence rules or rdate properties failed
on enumeration, they now
   will enumerate a single occurrence
### 0.0.7
 * Fixed a bug relating to properly recognizing ActiveRecord::TimeWithZone
 * DATETIME propertyvalues will now return an instance of TimeWithZone
instead of DateTime when
   activesupport is present, and it is appropriate. See the README for details
### 0.0.6
 * Added rake tasks to run specs with either the tzinfo gem or
activesupport (<=2.2)
 * Default rake task now runs both of these
### 0.0.5
 * Fixed a bug in occurrence enumeration reported by paulsm on github
### 0.0.4
 * Fixed a bug in imported timezones reported by paulsm on github
### 0.0.3
 * Added tzid method to Ruby Time and DateTime instances, and to
ActiveRecord::TimeWithZone if it is defined this method is used to
determine the desired
timezone when an instance of one of these classes is given as the
value of a datetime property.  If the tzid is nil then the default
tzid is used,
if it is set to :floating then the property will be a floating time.
 * Removed the ability to pass an array with a tzid string and a
date-time since the above made it unnecessary
 * The ruby datetime property returned from the ruby_value method on
the DateTime property will return an instance of ::DateTime with:
   ** The proper utc offset
   ** The tzid set to the right tzid
 * Made exdate/rdate building possible
 * Added a default_tzid attribute to the Calendar component, if this
attribute is not set for a particular calendar it will delegate to the
default set
for the DateTime property class.
 * Added fix patches from
   ** http://github.com/kjwierenga/ri_cal
   ** http://github.com/wesmaldonado/ri_cal

### 0.0.2
 * Fixed gemspec
## 0.0.1

* 
* 



[Rails] Re: Ruby w/ Apache mod_proxy

2009-06-07 Thread JannaB

Fred,

It does not appear to be -- when I check my gg/logs and gg/logs/
mongrel_ debug logs there is nothing mentioning an error here

On Jun 7, 9:42 am, Frederick Cheung 
wrote:
> On Jun 7, 2:37 pm, JannaB  wrote:
>
> > whenever I go to hithttp://127.0.0.1/ggIget a 404 not found error.
> > I am certain my document root is correct. Can you fellows here who
> > have done this tell me what I am missing? Thanks, Janna B.
>
> Who is throwing the 404 ? Is it rails telling you it doesn't have a
> controller called gg ?
>
> Fred
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Ruby w/ Apache mod_proxy

2009-06-07 Thread Frederick Cheung


On Jun 7, 2:37 pm, JannaB  wrote:

> whenever I go to hithttp://127.0.0.1/ggI get a 404 not found error.
> I am certain my document root is correct. Can you fellows here who
> have done this tell me what I am missing? Thanks, Janna B.

Who is throwing the 404 ? Is it rails telling you it doesn't have a
controller called gg ?

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



[Rails] Re: Ruby w/ Apache mod_proxy

2009-06-07 Thread JannaB

I must also mention I have:

LoadModule jk_module modules/mod_jk.so

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



[Rails] Ruby w/ Apache mod_proxy

2009-06-07 Thread JannaB

Yes, I know this is more specifically an Apache question, but you guys
in this group know this stuff forwards & backwards it seems.

I am running the glassfish gem (in lieu of mongrel) on port 81. If I
go to http://127.0.0.1:81 I get my rails app up beautifully.
Unfortunately, I am also required to have Apache 1.3.33 running on the
production server.

So I am trying to mod_proxy the site to the url with port 81 that I
know works. Here is how I have the VirtualHost in my httpd.conf file
set up:


ServerName gg
DocumentRoot C:/jruby/rails_apps/gg
ProxyPass /gg http://127.0.0.1:81
ProxyPassReverse /gg http://127.0.0.1:81

Order allow,deny
Allow from all



Ive also have unremmed:

LoadModule proxy_module modules/mod_proxy.so
-and-
AddModule mod_proxy.c

whenever I go to hit http://127.0.0.1/gg I get a 404 not found error.
I am certain my document root is correct. Can you fellows here who
have done this tell me what I am missing? Thanks, Janna B.


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



[Rails] Re: How to access parent property

2009-06-07 Thread Conrad Taylor

Hi, when I saw your models, I was thinking that you should have the  
following relationships:

Parent has many children

Child has many parents

Thus, you should have the following database tables:  children and  
parents.  By doing this, this becomes a many to many relationship.

Good luck,

-Conrad

Sent from my iPhone

On Jun 7, 2009, at 1:35 AM, developerinlondon   
wrote:

>
> Hi,
>
> I am having difficulties accessing parent properties/attributes from
> the child. Anyone could shed some lights onto this?
>
> Heres a sample code:
>
> class Parent < ActiveRecord::Base
>  :has_many => :childs
>  @connector
>  def before_save
>@connector = 'some connector object'
>0..9.do |count|
>  self.childs << Child.new
>  self.childs[count].connector = @connector
>end
>  end
> end
>
> class Child < ActiveRecord::Base
>  :belongs_to => :parent
>  @connector
>   def before_save
>  # code goes here to access @connector
>   end
> end
>
> The above is just a recreation of what I am looking to do. So
> basically I want to be able to access objects like the connector from
> the child, or even the parent itself by something like
> self.parent.attributes.
>
> Any ideas?
>
> thanks,
>
> nayeem
>
> >

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



[Rails] Re: Advice for quick fire DB replication with Rails

2009-06-07 Thread yitzhakbg

As nice as that sounds, it might not fly for two reasons:
1. Security: We probably won't be authorized to place the app on the
Internet. Until now, it's all privately hosted on closed connections
(perhaps if we could establish a closed connection...)
2. Latency. We're in Israel and the servers are in Europe.

Nonetheless, I'll ask my boss. Maybe...

Let's say we had to go it on our own, could you or anyone else
recommend the quicky recipe I'm seeking?

Thanks,
Yitzhak Bar Geva
http://www.nite.org.il/scripts/english/default.asp
P.S. That's our public site. As per today, the actual tests are
administered off-line.

On Jun 7, 3:00 pm, Roderick van Domburg  wrote:
> Yitzhak Bar Geva wrote:
> > We need an "out-of-the-box" sure-fire DB replication setup with
> > automatic failover for our Rails app. We haven't done it before. We'd
> > appreciate advice on what the simplest, surest, quickest method would
> > be (no more that one master/slave necessary, or two masters working
> > master/master).
>
> I consider MySQL the easiest for such a setup, in spite of all its
> quirks. Combine it with Heartbeat or CARP and you'll have a high
> availability configuration.
>
> If you'd really like it to be out-of-the-box, I'd like to chime in 
> withhttp://en.railscluster.nlwhere we've got this entire setup managed and
> ready to go for you.
>
> --
> Roderick van Domburghttp://www.railscluster.nl
>
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Administration Subsystem

2009-06-07 Thread Carl

As far as something that makes it easy to add new users, roles, etc
you could look into adding ActiveScaffold to your app.
http://wiki.github.com/activescaffold/active_scaffold

I was designed for acting as admin pages, and the interface is pretty
nice for things like that. I use it in a project for the main layout
because I like it. You get some simple search functions for free, the
author is very active in development (he's responded quickly when I
had problems, sometimes caused by my lack of experience with it). And
it is easy to install (just make sure you also install render
component plugin if you are using Rails 2.3 or higher (mentioned in
the readme)).

Carl

On Jun 6, 6:57 pm, "Mark A. Richman"  wrote:
> Can someone recommend a gem/plugin for administration of users, roles,
> preferences, etc.? I know various CMS's like Radiant and BrowserCMS
> have this, but I don't necessarily want to build all my apps on top of
> them. I'm using Authlogic for authentication and acl9 for
> authorization. I was more curious about user interface options. I'm
> tired of building out my own, and was wondering if there were an easy
> drop-in option. I may actually be better off building on top of a
> framework like Radiant. It just has to be extensible enough to add my
> custom models and workflow. Thoughts?
>
> Thanks,
> Mark
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Rake Tasks

2009-06-07 Thread Frederick Cheung



On Jun 7, 1:40 pm, "J. D."  wrote:
> Maurício Linhares wrote:
> > This custom file should be called scraper.rb and should be placed at
> > the /lib folder of your application. In a rake task you don't really
> > access or call controllers, you just run the task, which is telling
> > the scrapper to load the data and then save it to the DB.
>
> So, just to make sure I understand correctly..
>
> The scraper.rb file would go in the lib folder and my scraper.rake file
> would go in the lib\tasks folder?  The rake file - would I have to
> include anything to call that .rb file?  I'm sorry if I am
> misunderstanding this portion of the mechanics.
>
>
Because your task depends on :environment Rails is loaded, in
particular its dependency management is loaded so it will find your
Scraper class as long as it's in scraper.rb somewhere on its search
path. Don't take my word for it though, try it!

Fred

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



[Rails] Re: Rake Tasks

2009-06-07 Thread J. D.

Maurício Linhares wrote:
> This custom file should be called scraper.rb and should be placed at
> the /lib folder of your application. In a rake task you don't really
> access or call controllers, you just run the task, which is telling
> the scrapper to load the data and then save it to the DB.
> 

So, just to make sure I understand correctly..

The scraper.rb file would go in the lib folder and my scraper.rake file 
would go in the lib\tasks folder?  The rake file - would I have to 
include anything to call that .rb file?  I'm sorry if I am 
misunderstanding this portion of the mechanics.

> 
> You don't need to do anything else, Rails will automatically enable
> rubygems and by requiring hpricot you will tell it to load the gem.
> 

Thanks - that part is easy enough.  When I go to port my app to my real 
site, I will have to install hpricot there as well?  Or, can I include 
hpricot in vendor\plugins?

> 
> Now you have to learn the Rails database access framework,
> ActiveRecord, you should probably find plenty of material about it.
> 

This is the part that I'm currently studying/reading on and it's 
wonderful thus far.  I just didn't know if the rake task or the ruby 
file had to communicate with activerecord in a certain way..

i.e. - When I have a controller created it can communicate through the 
model and access the database.  Since the rake and rb file are not part 
of MVC, I just didn't know if it also used similar mechanics or not.

Thanks for the feedback.  I'll wait for the reply on the first note to 
figure it out..
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: How does controller call render when there's no render in action

2009-06-07 Thread Vojto

Sweet,

so I totally missed perform_action method :)

Thanks :)

On Jun 6, 3:01 pm, Frederick Cheung 
wrote:
> On Jun 6, 12:17 pm, Vojto  wrote:
>
> > I have a question.
>
> > "send(method, *arguments)" this calls action of a controller, right?
>
> not quite - (at least in the common) case, the method that gets called
> is perform_action, which calls default_render if you have not called
> render.
>
> Fred
>
>
>
> > But if there's no 'render' in action - how does it automatically call
> > render and renders the template for the action?
>
> > Thanks a lot
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Autocomplete Plugin - how can I use same "text_field_with_auto_complete" twice on one page?

2009-06-07 Thread Pat Shaughnessy

I ran into the same problem a while back and forked the plugin to fix
it; see:

http://patshaughnessy.net/repeated_auto_complete

Hope this helps, - pat

On Jun 2, 1:51 pm, Andy  wrote:
> Any ideas here?
>
> On May 28, 1:49 pm, Andy  wrote:
>
> > I'm trying to use an autocomplete twice on the same page, but only the
> > first one renders and functions.
>
> > I'm using the Autocomplete Plugin and Rails 2.1
>
> > Thanks,
> > Andy
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Advice for quick fire DB replication with Rails

2009-06-07 Thread Roderick van Domburg

Yitzhak Bar Geva wrote:
> We need an "out-of-the-box" sure-fire DB replication setup with
> automatic failover for our Rails app. We haven't done it before. We'd
> appreciate advice on what the simplest, surest, quickest method would
> be (no more that one master/slave necessary, or two masters working
> master/master).

I consider MySQL the easiest for such a setup, in spite of all its 
quirks. Combine it with Heartbeat or CARP and you'll have a high 
availability configuration.

If you'd really like it to be out-of-the-box, I'd like to chime in with 
http://en.railscluster.nl where we've got this entire setup managed and 
ready to go for you.

--
Roderick van Domburg
http://www.railscluster.nl

-- 
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: [ANN] SQL Server Adapter 2000/2005/2008

2009-06-07 Thread Roderick van Domburg

Ken Collins wrote:
> The SQL Server adapter I've been working on for the past 6 months or
> so now passes all the tests in rails 2.2 and 2.3 for all SQL Server
> versions. It is also Ruby 1.9 compatible, UTF-8 support, etc. Tons of
> info can be found in the README on github.

Many thanks for your hard work!

--
Roderick van Domburg
http://www.nedforce.com
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] How to access parent property

2009-06-07 Thread developerinlondon

Hi,

I am having difficulties accessing parent properties/attributes from
the child. Anyone could shed some lights onto this?

Heres a sample code:

class Parent < ActiveRecord::Base
  :has_many => :childs
  @connector
  def before_save
@connector = 'some connector object'
0..9.do |count|
  self.childs << Child.new
  self.childs[count].connector = @connector
end
  end
end

class Child < ActiveRecord::Base
  :belongs_to => :parent
  @connector
   def before_save
  # code goes here to access @connector
   end
end

The above is just a recreation of what I am looking to do. So
basically I want to be able to access objects like the connector from
the child, or even the parent itself by something like
self.parent.attributes.

Any ideas?

thanks,

nayeem

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



[Rails] Advice for quick fire DB replication with Rails

2009-06-07 Thread yitzhakbg

We need an "out-of-the-box" sure-fire DB replication setup with
automatic failover for our Rails app. We haven't done it before. We'd
appreciate advice on what the simplest, surest, quickest method would
be (no more that one master/slave necessary, or two masters working
master/master).
Which gems? Which DB recommended?
Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Rails way to do long running tasks

2009-06-07 Thread Phlip

Chris wrote:

>*   how to send emails without making the user wait

Either Thread.new{}, or a plugin called Spawn. You need the latter if your 
e-mails call templates which in turn call ActiveRecord. A separate thread 
requires a separate database connection, and Spawn handles this.

>*   how to execute long running tasks

The threading option has one flaw: If your web server expunges your Passenger 
module from memory, the thread lapses.

When sending a few emails, if you can't send them before process harvesting 
time, you have bigger problems than a missing email. Failing that analysis, you 
need an out-of-process solution like BackgroundRB. It runs in a daemon of its 
own and communicates with your app thru dRB. In exchange for a fatter and more 
fragile implementation, you get a process you can control directly. However...

>*   The best way to do periodic cron jobs in Rails

Create a folder called cron, write (using TDD!) a script that does what you 
need, and install it into your OS's cron system as the command line 
script/runner lib/my_script.rb.

If I needed to send e-mails, I would pool them up, then push them out with a 
cron. The previous two options allow communication back to the user in 
subsequent controller actions. You probably don't need that, so just configure 
a 
cron to run every 90 seconds, and send emails for up to 1 minute. Take a little 
care to not send the same email twice, and you are set.

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


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



[Rails] Re: How do i model this in Rails? (put down java equivalent design)

2009-06-07 Thread Frederick Cheung



On Jun 7, 3:29 am, Ritvvij  wrote:
> Hello guys,
>
> Need help!! Finding it hard to model the 'model' :P within the given
> rails associations.
>
> In java terms, my requirements are...
>
> There are 3 entities - module, chapter and activity.
>
> Chapter entity is a specilization of Module entity (inheritence)
> Activity entity is a specialization of Module entity (inheritence)
> And the tables would have looked like:
> 1. Module table = Module_Id, Entity_type, 
> 2. Chapter = Chapter_id, .
> 3. Activity = Activity_id, ..
>
> Hence, if I create a chapter then the tables would be populated as:
> Module table = Module_Id, Entity_type,  = values ( 100,
> chapter ,  )
> Chapter table = chapter_id, . = values ( 100,  )
> Basically, the ids of chapter and module would be same and module
> table would store the type.
>
That wouldn't be the rails way of doing  it. In rails you'd probably
either use single table inheritance or a polymorphic association.

Fred


> Now, if I create a activity then the tables would be populated as:
> Module table = Module_Id, Entity_type,  = values ( 101,
> activity ,  )
> Activity table = activity_id, . = values ( 100,  )
> Basically, the ids of activity and module would be same and module
> table would store the type.
>
> Can you please guide me how I can model it similarly in rails 2.3.2?
>
> Thanks in advance
> Ritvvij Parrilkh
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Mongrel not playing nicely with older rails/ruby

2009-06-07 Thread Frederick Cheung



On Jun 7, 2:09 am, rusty  wrote:
> Ok, now I get this...? Any clue as to what I'm missing?
>
that looks like your app is requiring ruby-debug but that the gem
isn't installed

Fred
> ** Starting Mongrel listening at 0.0.0.0:3000
> ** Starting Rails with development environment ...
> /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
> `require__': no such file to load -- ruby-debug (MissingSourceFile)
>         from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
> 21:in `require'
>         from /home/vhosts/dealer.benningtonmarine.com/config/../vendor/rails/
> activerecord/lib/../../activesupport/lib/active_support/
> dependencies.rb:147:in `require'
>         from /home/vhosts/dealer.benningtonmarine.com/config/environment.rb:
> 68
>         from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
> 21:in `require'
>         from /usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel/
> rails.rb:144:in `rails'
>         from /usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/bin/
> mongrel_rails:112:in `cloaker_'
>         from /usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/
> mongrel.rb:832:in `listener'
>         from /usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/bin/
> mongrel_rails:96:in `cloaker_'
>         from /usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/
> mongrel.rb:750:in `initialize'
>         from /usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/bin/
> mongrel_rails:83:in `run'
>         from /usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/lib/mongrel/
> command.rb:199:in `run'
>         from /usr/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3/bin/
> mongrel_rails:235
>         from /usr/local/bin/mongrel_rails:18
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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 way to do long running tasks

2009-06-07 Thread Chris

Hello Rails community,

  I would like to get some advices - I am writing a web application
that will be sending some emails and execute other long running tasks.

  Some of these tasks may take some time and I do not want the user
experience to be impacted. I would appreciate any pointers on advices
on these areas:

   *   how to send emails without making the user wait
   *   how to execute long running tasks
   *   The best way to do periodic cron jobs in Rails


Thank you for your help in advance.

Chris

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



[Rails] [ANN] SQL Server Adapter 2000/2005/2008

2009-06-07 Thread Ken Collins


Small announcement.

The SQL Server adapter I've been working on for the past 6 months or
so now passes all the tests in rails 2.2 and 2.3 for all SQL Server
versions. It is also Ruby 1.9 compatible, UTF-8 support, etc. Tons of
info can be found in the README on github.

http://github.com/rails-sqlserver/

I have also just recently published the de facto "activerecord-
sqlserver-adapter" gem name on RubyForge too.

http://rubyforge.org/frs/?group_id=8023

Lot's of details can be found on our Google group.

http://groups.google.com/group/rails-sqlserver-adapter


 - Cheers

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



[Rails] Learning Rails 1st Edition - Form Builders - Confuzzled

2009-06-07 Thread Rilindo Foster

Hi! Rails newbie here - so far, loving it.

Going through the Learnings Rails book and the for the most part, I am  
learning quite a bit (in spite of the errata). I did see something odd.

On 8.2.2, when I invoke the following private method:

def text_field(method, options={})
label_for(method, options) + super(method, options)
end
private
def label_for(method, options={})
label(:label || method) + ""
end

I should be able to print the label and the field:
<%= f.text_field :name %>

However, it came across on the view screen form, it came across. as:

Label
[FIELD BOX]

To actually display the label, I used this instead:

label(options.delete(:label) || method) + ""
Which is fine, but I am little confused - is ' label(:label || method)  
+ "" ' supposed to work as intended or was the behavior changed  
in the 2.3.x series (which I am using right now)?

  - Rilindo

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