Ruby on Rails Monday, January 31, 2011

http://www.mailr.org/

Mailr is the oldest project, but I don't think the original maintainer
is doing much on it. Worth having a look around github:

https://github.com/search?type=Everything&language=ruby&q=webmail

I think grabbing mailr from a fork there is preferably to the stale
download link on mailr.org.

There are a few newer options, but I'm having trouble finding them at
the moment. I haven't found "the one true Ruby/Rails based webmail
client" yet, personally.

Let me know if you do. I would love to get rid of a squirrelmail install I have.

Cheers,
Walter


On Tue, Feb 1, 2011 at 12:09 AM, shyam khadka <shyamkkhadka@gmail.com> wrote:
> Dear all,
>
> Do you know any webmail apps in Ruby on Rails ?? Though I found
> "mailr", it does not seem to be working with Rails 3.0.
>
> If anybody have any ideas about such apps, please do reply.
> 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+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

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

Ruby on Rails

Don't forget the ruote work flow engine



Karl Smith
January 31, 2011 4:01 PM

A few years back I used AASM. More recently, I just build state 
functionally by hand on an as needed basis. So I check out 
rubygems.org and low-and-behold there are many offerings. 

Here is a sampling: 
http://rubygems.org/gems/state_machine 
http://rubygems.org/gems/aasm 
http://rubygems.org/gems/acts_as_state_machine 
http://rubygems.org/gems/statemachine 
or all of them: 
http://rubygems.org/search?utf8=✓&query=state+machine 

My question is... which one is considered the current "standard" in 
state machine gems for rails 3? 

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

Ruby on Rails

Karl Smith wrote in post #978748:
> Hmm, so you are saying I could use a multi-field index (:user_id,
> :credit_card_number). Then, during inserts if a duplicate
> :credit_card_number is attempted a ActiveRecord::StatementInvalid would
> be
> generated, thus giving me an indication to try another
> credit_card_number.
>
> Sounds workable, but is it realistic?

Yes, this is really common in database design. There was a time when
composite primary keys were common and this is how those were enforced
to be unique. However, the use of the technique is not limited to
composite keys.

>
>> http://www.postgresql.org/docs/8.1/static/sql-createsequence.html
>>
> I don't like that, but nice to know.

Some databases use sequences exclusively for generating primary keys. As
opposed to providing auto-incrmenting column types... Just FYI.

>> My concern about locking the entire table would be that if something
>> went wrong then you might end up in a state where your entire table is
>> stuck in a locked state. I don't know for sure if that's an issue with
>> PostgreSQL, but something to consider.
>>
> Which concerns me as well.
>
>
>>
> I like that idea. That way I'm only locking that sequence table. This
> way I
> could use row level (pessimistic) locking.
>
> So, have you are anyone else tried this?

Yes, I have used this technique for generating serial sequences on a
number of projects. And you are correct that row level locking is used
to manage concurrent access.

http://www.postgresql.org/docs/8.1/static/sql-select.html#SQL-FOR-UPDATE-SHARE

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

Ruby on Rails

A few years back I used AASM. More recently, I just build state 
functionally by hand on an as needed basis. So I check out 
rubygems.org and low-and-behold there are many offerings. 

Here is a sampling: 
http://rubygems.org/gems/state_machine 
http://rubygems.org/gems/aasm 
http://rubygems.org/gems/acts_as_state_machine 
http://rubygems.org/gems/statemachine 
or all of them: 
http://rubygems.org/search?utf8=✓&query=state+machine 

My question is... which one is considered the current "standard" in 
state machine gems for rails 3? 

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

Ruby on Rails

Got it, thanks a lot guys!

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

Ruby on Rails



On Monday, January 31, 2011 2:16:02 PM UTC-7, Ruby-Forum.com User wrote:

I hope this "credit card" scenario is a contrived example. It seems to
me that it would be critical for the credit card number to be unique
across ALL users.

Yes, it's made up illustrative purposes.
 

You are correct. Row level locking is useless to prevent the duplication 

of values between rows due to the race condition during a SQL INSERT.

A unique index (possibly across multiple fields) would prevent such
duplication.

Hmm, so you are saying I could use a multi-field index (:user_id, :credit_card_number). Then, during inserts if a duplicate :credit_card_number is attempted a ActiveRecord::StatementInvalid would be generated, thus giving me an indication to try another credit_card_number.

Sounds workable, but is it realistic?
 

> Is my only option to lock the table, find the highest credit card
> number,
> add 1, update the new credit card number, save, and release the table
> lock?

It might be possible for you to use a sequence. But, in your case you
would need a separate sequence for each user if I understand you
correctly. Although this might work it may not be appropriate in your
case.

http://www.postgresql.org/docs/8.1/static/sql-createsequence.html

I don't like that, but nice to know.
 

My concern about locking the entire table would be that if something
went wrong then you might end up in a state where your entire table is
stuck in a locked state. I don't know for sure if that's an issue with
PostgreSQL, but something to consider.

Which concerns me as well.
 

There may also be other considerations if you ever have a need to use
more that one database backend for the purposes of scaling.

I would also try to avoid having to use a "max value" query every time
you needed to find the next number in sequence. You could instead create
a table that contains a foreign key to your users table with the next
sequence value stored there. You would then increment that value for
each insert similar to how database sequences work. This way you should
only have to be concerned about concurrent access to the table used for
sequencing.

I like that idea. That way I'm only locking that sequence table. This way I could use row level (pessimistic) locking.

So, have you are anyone else tried this?

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

Ruby on Rails

You have to performance test based upon likely usage scenarios (click flows) for your app. I've never come across good metrics in any programming language for "how many users can a web app handle". It just depends too much on how the users use the app and what the app does to respond to those users.

Best Wishes,
Peter

On Jan 31, 2011, at 4:18 PM, Tom Ha wrote:

> Thanks, Fred!
>
> 1 question back - if you say...
>
>> ...and your instances can handle 10
>> requests/s then...
>
> ...is the "10 requests/s" per instance the average capacity of a Ruby
> instance? If not, do such figures exist or make any sense? Or would I
> have to calculate my own instance capacity, simply based on what my
> server's hardware actually swallows during usage?
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>

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

Ruby on Rails

Thanks, Fred!

1 question back - if you say...

> ...and your instances can handle 10
> requests/s then...

...is the "10 requests/s" per instance the average capacity of a Ruby
instance? If not, do such figures exist or make any sense? Or would I
have to calculate my own instance capacity, simply based on what my
server's hardware actually swallows during usage?

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

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

Ruby on Rails

Karl Smith wrote in post #978730:
> I need to generate a unique serial number in numerical order, but only
> unique for each user.
>
> For example, each user can create a new credit card and each new credit
> card
> must start at a predetermined number and increment by 1 for each new
> credit
> card for that user. Thus, credit card numbers are unique for a user but
> not
> unique for the CreditCard table. And yes, it is absolutely critical that
> credit card numbers are always unique for each user.

I hope this "credit card" scenario is a contrived example. It seems to
me that it would be critical for the credit card number to be unique
across ALL users.

> http://apidock.com/rails/ActiveRecord/Locking/Pessimistic
>
> I'm using PostgreSQL.
>
> Looking through the docs it doesn't appear that I can use either
> pessimistic
> locking or optimistic locking. Maybe I'm wrong?

You are correct. Row level locking is useless to prevent the duplication
of values between rows due to the race condition during a SQL INSERT.

A unique index (possibly across multiple fields) would prevent such
duplication.

> Is my only option to lock the table, find the highest credit card
> number,
> add 1, update the new credit card number, save, and release the table
> lock?

It might be possible for you to use a sequence. But, in your case you
would need a separate sequence for each user if I understand you
correctly. Although this might work it may not be appropriate in your
case.

http://www.postgresql.org/docs/8.1/static/sql-createsequence.html

My concern about locking the entire table would be that if something
went wrong then you might end up in a state where your entire table is
stuck in a locked state. I don't know for sure if that's an issue with
PostgreSQL, but something to consider.

There may also be other considerations if you ever have a need to use
more that one database backend for the purposes of scaling.

I would also try to avoid having to use a "max value" query every time
you needed to find the next number in sequence. You could instead create
a table that contains a foreign key to your users table with the next
sequence value stored there. You would then increment that value for
each insert similar to how database sequences work. This way you should
only have to be concerned about concurrent access to the table used for
sequencing.

Good luck, I hope this helps at least a little.

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

Ruby on Rails

On Jan 31, 8:55 pm, Tom Ha <li...@ruby-forum.com> wrote:

>
> I really do hope it's not 1 ruby instance per user that's necessary,
> because the instances I saw on my server were all using between 120MB
> and 140MB of memory, which seems huge to me (I'm a novice to all that,
> though).
>

It's a function of how much traffic you'll be handling. If you need to
be able to handle 100 requests/s and your instances can handle 10
requests/s then you'll need about 10 instances. How that maps onto
numbers of users depends on your site.

Fred
> Thank you very much for any explanations!
> Tom
>
> --
> 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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Ruby on Rails

Hi there,

what does the number of Ruby instances a server keeps running really
depend on?

Can I model/calculate that somehow as a function of the number of users
on the website or do I just have to wait and see how the situation
evolves?

I really do hope it's not 1 ruby instance per user that's necessary,
because the instances I saw on my server were all using between 120MB
and 140MB of memory, which seems huge to me (I'm a novice to all that,
though).

Thank you very much for any explanations!
Tom

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

Ruby on Rails

On Jan 31, 6:33 pm, Alessandra <acard...@fcm.unicamp.br> wrote:
> Hello everybody,
>
> I'm trying to use Ruby on Rails accessing a pre-existing database on
> SQL Server 2000.
> After some research I found that it should use the gem activerecord-
> sqlserver-adapter. Create a connection via ODBC to the
> desired base, and creating a database user for access it. We also
> configured the database.yml in the following ways:
>
>     development:
>       adapter: sqlserver
>       mode: odbc
>       dsn: Driver = {SQL Server}; Server = myserver; Database =
> minha_base; Trusted_Connection = yes;
>
>     development:
>       adapter: sqlserver
>       dsn: my_dsn
>       mode: odbc
>       database: my_base
>       username: myuser
>       password:
>
> I've tried tried using the following versions, but none worked:
> Ruby 1.9.2, Rails 3.0.9, activerecord-sqlserver-adapter 3.0.9
> (descrobi after which it was to sqlserver 2005 and 2008)
> Ruby 1.9.2, Rails 3.0.9, activerecord-sqlserver-adapter 2.2.18
> (version for Sql 2000.2005, 2008)
> Ruby 1.8.6, Rails 2.3.5, activerecord-sqlserver-adapter 2.2.18
> Ruby 1.8.7, Rails 2.3.5, activerecord-sqlserver-adapter 2.2.18
> Ruby 1.8.7, Rails 2.3.5, activerecord-sqlserver-adapter 2.3.14
> (version for Sql 2000.2005, 2008)
> Ruby 1.8.7, Rails 2.0.2, activerecord-sqlserver-adapter 2.2.18
>
> Could someone help me?

You have to install ruby-odbc (http://www.ch-werner.de/rubyodbc/) too.

Regards,
Boško Ivanišević

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

Ruby on Rails

On Jan 31, 2011, at 9:38 PM, Karl Smith wrote:

> I need to generate a unique serial number in numerical order, but only
> unique for each user.

if worst comes to worst, you can always use one sequence per user:

http://www.postgresql.org/docs/8.1/static/sql-createsequence.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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Ruby on Rails

I need to generate a unique serial number in numerical order, but only unique for each user.


For example, each user can create a new credit card and each new credit card must start at a predetermined number and increment by 1 for each new credit card for that user. Thus, credit card numbers are unique for a user but not unique for the CreditCard table. And yes, it is absolutely critical that credit card numbers are always unique for each user.

http://apidock.com/rails/ActiveRecord/Locking/Pessimistic

I'm using PostgreSQL.

Looking through the docs it doesn't appear that I can use either pessimistic locking or optimistic locking. Maybe I'm wrong?

Is my only option to lock the table, find the highest credit card number, add 1, update the new credit card number, save, and release the table lock?

Karl


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

Ruby on Rails

PDFBox is the library I'm using on a current project: http://pdfbox.apache.org/
There is a link to "Extract Text" under Command Line Utilities. There is also a section called "Text Extraction" under Tutorials.

There is a ruby command line utility that wraps PDFBox called Docsplit: http://documentcloud.github.com/docsplit/ that might be worth looking into.

For pdftk: http://pdf-toolkit.rubyforge.org/classes/PDF/Toolkit.html#M000003


Hope this helps,
Garrett Lancaster



Walter Lee Davis
January 31, 2011 1:58 PM

I don't see how these relate to the question -- they are apparently designed to generate PDFs rather than to extract text from existing PDF documents. Can you point to an example where these libraries can be used in that fashion? I'd love to use something more professionally developed than my own system.

Walter

On Jan 31, 2011, at 12:36 PM, Garrett Lancaster wrote:

pdftk, pdfbox (java), pdfkit

Garrett Lancaster




Walter Lee Davis
January 31, 2011 11:32 AM


On Jan 31, 2011, at 12:12 PM, Tushar Gandhi wrote:


I did this using Paperclip and defining a processor for Paperclip as follows:



Garrett Lancaster
January 31, 2011 11:36 AM

pdftk, pdfbox (java), pdfkit

Garrett Lancaster



Walter Lee Davis
January 31, 2011 11:32 AM


On Jan 31, 2011, at 12:12 PM, Tushar Gandhi wrote:


I did this using Paperclip and defining a processor for Paperclip as follows:

#lib/paperclip_processors/text.rb
module Paperclip
  # Handles extracting plain text from PDF file attachments
  class Text < Processor

    attr_accessor :whiny

    # Creates a Text extract from PDF
    def make
      src = @file
      dst = Tempfile.new([@basename, 'txt'].compact.join("."))
      command = <<-end_command
        "#{ File.expand_path(src.path) }"
        "#{ File.expand_path(dst.path) }"
      end_command

      begin
        success = Paperclip.run("/usr/bin/pdftotext -nopgbrk", command.gsub(/\s+/, " "))
        Rails.logger.info "Processing #{src.path} to #{dst.path} in the text processor."
      rescue PaperclipCommandLineError
        raise PaperclipError, "There was an error processing the text for #{@basename}" if @whiny
      end
      dst
    end
  end
end

#app/models/document.rb
  has_attached_file :pdf,:styles => { :text => { :fake => 'variable' } }, :processors => [:text]
  after_post_process :extract_text

  private
  def extract_text
    file = File.open("#{pdf.queued_for_write[:text].path}","r")
    plain_text = ""
    while (line = file.gets)
      plain_text << Iconv.conv('ASCII//IGNORE', 'UTF8', line)
    end
    self.plain_text = plain_text #text column to hold the extracted text for searching
  end

I had to find and install the creaky-old pdftotext library on my server (happily, there was an apt-get bundle for it) and configure the path correctly. When Paperclip accepts a PDF upload, it creates a text extraction of that file and saves it in system/pdfs/:id/text/filename.pdf. Note that while it has a .pdf extension, the file itself is actually just the plain text extracted from the original pdf. After quite a lot of googling and begging my local Ruby group, I got the recipe for ripping open that text file and reading it into a variable to store on the record. The text you get out of pdftotext will vary wildly in quality and comprehensiveness, but since all I needed was a way to get a simple search system fed, it works fine for my needs. I never show this text to anyone, just use it as the "keywords" for search. You may want/need to present an editing field for the administrator to clean up these extracted texts.

Walter



Tushar Gandhi
January 31, 2011 11:12 AM

Hi,
In my upcoming application we are uploading the pdf files.
After uploading the pdf file I have to extract the text from pdf and
display it to user.
can anyone tell me how to extract text from pdf file?
Is there any plugin or gem present for this?
Thanks,
Tushar

Ruby on Rails

I don't see how these relate to the question -- they are apparently
designed to generate PDFs rather than to extract text from existing
PDF documents. Can you point to an example where these libraries can
be used in that fashion? I'd love to use something more professionally
developed than my own system.

Walter

On Jan 31, 2011, at 12:36 PM, Garrett Lancaster wrote:

> pdftk, pdfbox (java), pdfkit
>
> Garrett Lancaster
>
>>

Ruby on Rails

Oh, will get back to you on whether this can be reproduced on a
minimal app...

On Jan 31, 4:26 am, Xavier Noria <f...@hashref.com> wrote:
> On Mon, Jan 31, 2011 at 3:48 AM, tashfeen.ekram
>
> <tashfeen.ek...@gmail.com> wrote:
> > when i run rake tasks, i run into a strange problem when running it in
> > production mode. it loads all of the files in the directory app/
> > runners/cron. when i run the rake task with config.cache_classes set
> > to true (as it is set in environment/production.rb) then it seems to
> > load those files in that directory upon execution of the rake command.
> > however, those files are not loaded when it is set to false.
>
> > i have checked my application, boot, and environment files and i am
> > not loading that directory.
>
> Can you reproduce it in a minimal application?
>
> I see from the other thread that the application runs Rails 3. Just in
> case it was migrated from Rails 2 let me comment that in Rails 2
> custom directories under app are not eager loaded, while they are in
> Rails 3. In case it rings a bell.
>
> Having said that, eager loading is not triggered for bare rake tasks
> that do not depend on the builtin :environment task. And for tasks
> that do depend there's a global flag called $rails_rake_task set to
> true within :environment that prevents eager loading from being run at
> all. Thus, as far as rake tasks is concerned, it shouldn't happen *in
> any case* unless there's some custom behavior somewhere.

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

Ruby on Rails

So, based on what you are saying, these must be loaded somehow from a
custom load that I added?

The thing I find confusing though is that should not the same thing
happen even if classes are not cached?

Are there any other files I should look at to track down where this
include might be coming from?

Finally, where is the ideal place to put custom files?

Thanks for you help. :)

On Jan 31, 4:26 am, Xavier Noria <f...@hashref.com> wrote:
> On Mon, Jan 31, 2011 at 3:48 AM, tashfeen.ekram
>
> <tashfeen.ek...@gmail.com> wrote:
> > when i run rake tasks, i run into a strange problem when running it in
> > production mode. it loads all of the files in the directory app/
> > runners/cron. when i run the rake task with config.cache_classes set
> > to true (as it is set in environment/production.rb) then it seems to
> > load those files in that directory upon execution of the rake command.
> > however, those files are not loaded when it is set to false.
>
> > i have checked my application, boot, and environment files and i am
> > not loading that directory.
>
> Can you reproduce it in a minimal application?
>
> I see from the other thread that the application runs Rails 3. Just in
> case it was migrated from Rails 2 let me comment that in Rails 2
> custom directories under app are not eager loaded, while they are in
> Rails 3. In case it rings a bell.
>
> Having said that, eager loading is not triggered for bare rake tasks
> that do not depend on the builtin :environment task. And for tasks
> that do depend there's a global flag called $rails_rake_task set to
> true within :environment that prevents eager loading from being run at
> all. Thus, as far as rake tasks is concerned, it shouldn't happen *in
> any case* unless there's some custom behavior somewhere.

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

Ruby on Rails

Hi,

I am trying to install Rails on my Max OS X 10.6.5.

I run the "gem install rails" command and it seems to stop short,
yielding a "File not found: lib"
message. There is no "Error" message but the installation just stops.

The command and the output are as follows...

if4it$ sudo gem install rails
Fetching: railties-3.0.3.gem (100%)
Fetching: rails-3.0.3.gem (100%)
Successfully installed thor-0.14.6
Successfully installed railties-3.0.3
Successfully installed bundler-1.0.9
Successfully installed rails-3.0.3
4 gems installed
Installing ri documentation for thor-0.14.6...
Installing ri documentation for railties-3.0.3...
Installing ri documentation for bundler-1.0.9...
Installing ri documentation for rails-3.0.3...
File not found: lib


Do any of you have any suggestions as to what this means and what the
follow-up steps would be to correct it and complete the installation?

Thanks, in advance, for any assistance you can offer.

My Best,

Frank

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

Ruby on Rails



On Mon, Jan 31, 2011 at 12:03 PM, PalaniKannan K <kpalanikannan@gmail.com> wrote:
Hi david,

thanks for your suggestion.

I tried 'case' statement before. But, I am using 'if' statements in the array loops of @descriptions and description.table2. @descriptions is an array generated in table 1's controller. If I wish to 'use' either table 1 or table 2 models... I am getting into problem to merge this two array loops. how i can use @desctipion (array generated in table1 controller) in the model of table 2? Kindly help this regard.

I would think also you might be able to use includes or joins in your activerecord call, and/or a where condition to 'merge' your results. Personally I would write out in pseudo-code what trying to do and then get as close to the db first (using activerecord in this case).
 

--
with regards,

palani kannan

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

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

Ruby on Rails

Here's a gem based on an earlier plugin for this sort of thing:

https://github.com/kete/http_url_validation_improved

It's not without issues though. The big one is that URLs these days
can have unicode in them and the URI library (at least in Ruby 1.8.7)
treats them as invalid. Feel free to fork and improve.

Cheers,
Walter

On Mon, Jan 31, 2011 at 11:10 PM, agathe begault
<agathe.begault@gmail.com> wrote:
> Hello everybody,
>
> I'm trying to link some files from some servers like Sharepoint to my
> application.
>
> my problem is when the link is not good, I'm redirected in a 404 error
> page (which is normal :p).
>
> I would like to know how to something like a validation method to
> display the button to download if the link is correct and to display a
> red button if it's not.
>
> I tried some different things like :
>
> def remote_file_exist?(url)
>  res = Net::HTTP.get_response(URI.parse(url)) rescue SocketError
>  res
> end
>
>
> Without success. Each time some files were considered as unvalide
> while they were valid and vice versa.
>
> It maybe comes from my code, that's why i continue to try other
> possibilities.
>
> Any idea or suggestion ?
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

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

Ruby on Rails

Dear Ar Chron,

these are hierarchial conditions. so i need in hierarchial lever... the conditions as well as execution content are "columns of @description from table1 and description.tale2".

--
With Regards,
Palani Kannan

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

Ruby on Rails

I wrote a plugin that requires attachment_fu and some unixy utilities behind the scenes for this several years back:



It works reliably in Rails 2.x apps. I haven't tried it with Rails 3 yet. You could fork it and update (make it work with PaperClip or Rails 3) it you like or just have a gander for example code.

Cheers,
Walter



On Tue, Feb 1, 2011 at 6:36 AM, Garrett Lancaster <glancast@garrettlancaster.com> wrote:
pdftk, pdfbox (java), pdfkit

Garrett Lancaster



Walter Lee Davis
January 31, 2011 11:32 AM


On Jan 31, 2011, at 12:12 PM, Tushar Gandhi wrote:


I did this using Paperclip and defining a processor for Paperclip as follows:

#lib/paperclip_processors/text.rb
module Paperclip
  # Handles extracting plain text from PDF file attachments
  class Text < Processor

    attr_accessor :whiny

    # Creates a Text extract from PDF
    def make
      src = @file
      dst = Tempfile.new([@basename, 'txt'].compact.join("."))
      command = <<-end_command
        "#{ File.expand_path(src.path) }"
        "#{ File.expand_path(dst.path) }"
      end_command

      begin
        success = Paperclip.run("/usr/bin/pdftotext -nopgbrk", command.gsub(/\s+/, " "))
        Rails.logger.info "Processing #{src.path} to #{dst.path} in the text processor."
      rescue PaperclipCommandLineError
        raise PaperclipError, "There was an error processing the text for #{@basename}" if @whiny
      end
      dst
    end
  end
end

#app/models/document.rb
  has_attached_file :pdf,:styles => { :text => { :fake => 'variable' } }, :processors => [:text]
  after_post_process :extract_text

  private
  def extract_text
    file = File.open("#{pdf.queued_for_write[:text].path}","r")
    plain_text = ""
    while (line = file.gets)
      plain_text << Iconv.conv('ASCII//IGNORE', 'UTF8', line)
    end
    self.plain_text = plain_text #text column to hold the extracted text for searching
  end

I had to find and install the creaky-old pdftotext library on my server (happily, there was an apt-get bundle for it) and configure the path correctly. When Paperclip accepts a PDF upload, it creates a text extraction of that file and saves it in system/pdfs/:id/text/filename.pdf. Note that while it has a .pdf extension, the file itself is actually just the plain text extracted from the original pdf. After quite a lot of googling and begging my local Ruby group, I got the recipe for ripping open that text file and reading it into a variable to store on the record. The text you get out of pdftotext will vary wildly in quality and comprehensiveness, but since all I needed was a way to get a simple search system fed, it works fine for my needs. I never show this text to anyone, just use it as the "keywords" for search. You may want/need to present an editing field for the administrator to clean up these extracted texts.

Walter



Tushar Gandhi
January 31, 2011 11:12 AM

Hi,
In my upcoming application we are uploading the pdf files.
After uploading the pdf file I have to extract the text from pdf and
display it to user.
can anyone tell me how to extract text from pdf file?
Is there any plugin or gem present for this?
Thanks,
Tushar

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

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

Ruby on Rails

PalaniKannan K wrote in post #978680:

You have a few paths which will yield nothing (no executions, no
output).

if !condition1 - nothing occurs
if condition1 and condition2 and !condition3 - nothing occurs
if condition1 and !condition2 and !condition6 - nothing occurs

Scope your data access (either description or tale2) to eliminate those
cases from the data considered, then simplify your logic.

Less data to paw through with the rest of the code, and case might be a
better construct for readability.

BTW, what are all those execution steps?

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

Ruby on Rails

Hi david,

thanks for your suggestion.

I tried 'case' statement before. But, I am using 'if' statements in the array loops of @descriptions and description.table2. @descriptions is an array generated in table 1's controller. If I wish to 'use' either table 1 or table 2 models... I am getting into problem to merge this two array loops. how i can use @desctipion (array generated in table1 controller) in the model of table 2? Kindly help this regard.

--
with regards,

palani kannan

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

Ruby on Rails



On Mon, Jan 31, 2011 at 10:34 AM, PalaniKannan K <kpalanikannan@gmail.com> wrote:

Hi,

I have hierarchical "if loops" like this

<% @descriptions.each_with_index do |description, i| %> <% description.tale2.each do |tax_ref| %>
<% if condition %>
<% if condition %> <% if condition %>
<%= $text_first_describe%> <%= $paren_author_yr %> <% ref_sp_uniq.each_with_index do |ref, i| %> <% if ref == tax_ref.ref_wo_brace%> <% execution %>
<% elsif i == (ref_sp_uniq.size - 1)%> <%# @ref_desc = "#{@ref_desc_numb}. #{tax_ref.ref_wo_brace}" %> <% end %> <% end %> <% if condition %> <% execution %>
<% elsif condition %> <% execution %> <% elsif taxon_name.emend_author_year %>
<%= print %> <% else %>
<%= print %>
<% end %> <% end %> <% else %> <% if condition %> <%= print %> <% ref_sp_uniq.each_with_index do |ref, i| %> <% if condition %> <% execution %>
<% elsif condition %> <% execution %>
<% end %> <% end %> <% if condition %> <% execution %>
<% elsif condition %> <% execution %>
<% elsif condition %> <% execution %>
<% else %> <% execution %>
<% end %> <% end %> <% end %> <% end %> <% end %>
<% end %>


Hi Palani... first thing is find a way to move your logic to the Model. Your html.erb code really should be as much as possible just to present your data. Secondly, using the 'case' construction might help:

a = 1
case somthing
when 'x':
  do somthing
when 'y'
  do something else
when 'z'
  do another thing....
....
end


 

Kindly suggest me possible way to reduce this kind of junk "if loops".


--
With Regards,
Palani Kannan. K,

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

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

Ruby on Rails

Estou tentando usar o Ruby on Rails acessando uma
base Sql Server 2000 pré existente.
Depois de algumas pesquisas verifiquei q deveria usar
a gem activerecord-sqlserver-adapter. Criar uma
conexão via odbc para o base desejada, e na base de
configurei o database.yml das seguintes maneiras:
dados criando um usuário para ter acesso. Também

development:
adapter: sqlserver
mode: odbc
dsn: Driver={SQL
Server};Server=meu_servidor;Database=minha_base;Trusted_Connection=yes;

development:
adapter: sqlserver
dsn: meu_dsn
mode: odbc
database: minha_base
username: meu_usuario
password:

Já tentei tentei usar as seguintes versões, mas
nenhuma funcionou:
Ruby 1.9.2, Rails 3.0.9, activerecord-sqlserver-adapter 3.0.9 ( que
depois
descrobi que era para sqlserver 2005 e 2008)
Ruby 1.9.2, Rails 3.0.9,activerecord-sqlserver-adapter 2.2.18 (versão
para
Sql server 2000,2005, 2008)
Ruby 1.8.6, Rails 2.3.5,activerecord-sqlserver-adapter 2.2.18
Ruby 1.8.7, Rails 2.3.5,activerecord-sqlserver-adapter 2.2.18
Ruby 1.8.7, Rails 2.3.5,activerecord-sqlserver-adapter 2.3.14 (versão
paraSql server 2000,2005, 2008)
Ruby 1.8.7, Rails 2.0.2,activerecord-sqlserver-adapter 2.2.18

Alguem poderia me ajudar?

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

Ruby on Rails

pdftk, pdfbox (java), pdfkit

Garrett Lancaster



Walter Lee Davis
January 31, 2011 11:32 AM


On Jan 31, 2011, at 12:12 PM, Tushar Gandhi wrote:


I did this using Paperclip and defining a processor for Paperclip as follows:

#lib/paperclip_processors/text.rb
module Paperclip
  # Handles extracting plain text from PDF file attachments
  class Text < Processor

    attr_accessor :whiny

    # Creates a Text extract from PDF
    def make
      src = @file
      dst = Tempfile.new([@basename, 'txt'].compact.join("."))
      command = <<-end_command
        "#{ File.expand_path(src.path) }"
        "#{ File.expand_path(dst.path) }"
      end_command

      begin
        success = Paperclip.run("/usr/bin/pdftotext -nopgbrk", command.gsub(/\s+/, " "))
        Rails.logger.info "Processing #{src.path} to #{dst.path} in the text processor."
      rescue PaperclipCommandLineError
        raise PaperclipError, "There was an error processing the text for #{@basename}" if @whiny
      end
      dst
    end
  end
end

#app/models/document.rb
  has_attached_file :pdf,:styles => { :text => { :fake => 'variable' } }, :processors => [:text]
  after_post_process :extract_text

  private
  def extract_text
    file = File.open("#{pdf.queued_for_write[:text].path}","r")
    plain_text = ""
    while (line = file.gets)
      plain_text << Iconv.conv('ASCII//IGNORE', 'UTF8', line)
    end
    self.plain_text = plain_text #text column to hold the extracted text for searching
  end

I had to find and install the creaky-old pdftotext library on my server (happily, there was an apt-get bundle for it) and configure the path correctly. When Paperclip accepts a PDF upload, it creates a text extraction of that file and saves it in system/pdfs/:id/text/filename.pdf. Note that while it has a .pdf extension, the file itself is actually just the plain text extracted from the original pdf. After quite a lot of googling and begging my local Ruby group, I got the recipe for ripping open that text file and reading it into a variable to store on the record. The text you get out of pdftotext will vary wildly in quality and comprehensiveness, but since all I needed was a way to get a simple search system fed, it works fine for my needs. I never show this text to anyone, just use it as the "keywords" for search. You may want/need to present an editing field for the administrator to clean up these extracted texts.

Walter



Tushar Gandhi
January 31, 2011 11:12 AM

Hi,
In my upcoming application we are uploading the pdf files.
After uploading the pdf file I have to extract the text from pdf and
display it to user.
can anyone tell me how to extract text from pdf file?
Is there any plugin or gem present for this?
Thanks,
Tushar

Ruby on Rails

Hello everybody,

I'm trying to use Ruby on Rails accessing a pre-existing database on
SQL Server 2000.
After some research I found that it should use the gem activerecord-
sqlserver-adapter. Create a connection via ODBC to the
desired base, and creating a database user for access it. We also
configured the database.yml in the following ways:

development:
adapter: sqlserver
mode: odbc
dsn: Driver = {SQL Server}; Server = myserver; Database =
minha_base; Trusted_Connection = yes;

development:
adapter: sqlserver
dsn: my_dsn
mode: odbc
database: my_base
username: myuser
password:


I've tried tried using the following versions, but none worked:
Ruby 1.9.2, Rails 3.0.9, activerecord-sqlserver-adapter 3.0.9
(descrobi after which it was to sqlserver 2005 and 2008)
Ruby 1.9.2, Rails 3.0.9, activerecord-sqlserver-adapter 2.2.18
(version for Sql 2000.2005, 2008)
Ruby 1.8.6, Rails 2.3.5, activerecord-sqlserver-adapter 2.2.18
Ruby 1.8.7, Rails 2.3.5, activerecord-sqlserver-adapter 2.2.18
Ruby 1.8.7, Rails 2.3.5, activerecord-sqlserver-adapter 2.3.14
(version for Sql 2000.2005, 2008)
Ruby 1.8.7, Rails 2.0.2, activerecord-sqlserver-adapter 2.2.18

Could someone help me?

Thankfully!

Ale

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

Ruby on Rails

On Jan 31, 2011, at 12:12 PM, Tushar Gandhi wrote:

> Hi,
> In my upcoming application we are uploading the pdf files.
> After uploading the pdf file I have to extract the text from pdf and
> display it to user.
> can anyone tell me how to extract text from pdf file?
> Is there any plugin or gem present for this?
> Thanks,
> Tushar
>

I did this using Paperclip and defining a processor for Paperclip as
follows:

#lib/paperclip_processors/text.rb
module Paperclip
# Handles extracting plain text from PDF file attachments
class Text < Processor

attr_accessor :whiny

# Creates a Text extract from PDF
def make
src = @file
dst = Tempfile.new([@basename, 'txt'].compact.join("."))
command = <<-end_command
"#{ File.expand_path(src.path) }"
"#{ File.expand_path(dst.path) }"
end_command

begin
success = Paperclip.run("/usr/bin/pdftotext -nopgbrk",
command.gsub(/\s+/, " "))
Rails.logger.info "Processing #{src.path} to #{dst.path} in
the text processor."
rescue PaperclipCommandLineError
raise PaperclipError, "There was an error processing the text
for #{@basename}" if @whiny
end
dst
end
end
end

#app/models/document.rb
has_attached_file :pdf,:styles => { :text => { :fake =>
'variable' } }, :processors => [:text]
after_post_process :extract_text

private
def extract_text
file = File.open("#{pdf.queued_for_write[:text].path}","r")
plain_text = ""
while (line = file.gets)
plain_text << Iconv.conv('ASCII//IGNORE', 'UTF8', line)
end
self.plain_text = plain_text #text column to hold the extracted
text for searching
end

I had to find and install the creaky-old pdftotext library on my
server (happily, there was an apt-get bundle for it) and configure the
path correctly. When Paperclip accepts a PDF upload, it creates a text
extraction of that file and saves it in system/pdfs/:id/text/
filename.pdf. Note that while it has a .pdf extension, the file itself
is actually just the plain text extracted from the original pdf. After
quite a lot of googling and begging my local Ruby group, I got the
recipe for ripping open that text file and reading it into a variable
to store on the record. The text you get out of pdftotext will vary
wildly in quality and comprehensiveness, but since all I needed was a
way to get a simple search system fed, it works fine for my needs. I
never show this text to anyone, just use it as the "keywords" for
search. You may want/need to present an editing field for the
administrator to clean up these extracted texts.

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

Ruby on Rails

Bente Pieck wrote in post #978687:

>
> Is this what you need?
>
>

> --
> best regards
> Bente Pieck

Yes! I've used some of this without luck but I probably did something
wrong. With your help, your code, I'm sure I'll get it right. Thank you
very much. :-)

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

Ruby on Rails

Hi,
In my upcoming application we are uploading the pdf files.
After uploading the pdf file I have to extract the text from pdf and
display it to user.
can anyone tell me how to extract text from pdf file?
Is there any plugin or gem present for this?
Thanks,
Tushar

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

Ruby on Rails

I think, I still missunderstand you. But perhaps this is, what you need:

You want to iterate through errors:

@user.errors.each do |attr, message|
  do something with attr and message
end

If you want an array of all full_messages, use:
@user.errors.full_messages
(how they are handling it in this episode: http://railscasts.com/episodes/211-validations-in-rails-3)

@user.errors.generate_message(:firstname)

Or if you need the other methods of @user.errors, look here:
http://api.rubyonrails.org/
ActiveModel::Errors

Is this what you need?


PS:

validates :firstname, :presence => true, :message => "First name is missing" 
I think this is confused mix of old
validates_presence_of :firstname, :message => message
and newer sexy validations
validates :attribute, :presence => options_hash/true/array/

if you look in the source:
75 validations = defaults.slice!(:if, :unless, :on, :allow_blank, :allow_nil)  only these 5 options are possible global-options. :message is not one of them. So I am sure, your way won't do what you want it to do. 




On 28/01/11 17:03, Paul Bergstrom wrote:
Bente Pieck wrote in post #978180: 
On 28/01/11 15:54, Paul Bergstrom wrote: 
Did you mean: validates :firstname, :presence => {:message => "First name is missing"} ?   -- best regards Bente Pieck 
Yes. But I've also seen alidates :firstname, :presence => true, :message  => "First name is missing"  However that's not my problem. How do I get hold of the error message?  


--  best regards Bente Pieck

Ruby on Rails

Hi,

I have hierarchical "if loops" like this

<% @descriptions.each_with_index do |description, i| %> <% description.tale2.each do |tax_ref| %>
<% if condition %>
<% if condition %> <% if condition %>
<%= $text_first_describe%> <%= $paren_author_yr %> <% ref_sp_uniq.each_with_index do |ref, i| %> <% if ref == tax_ref.ref_wo_brace%> <% execution %>
<% elsif i == (ref_sp_uniq.size - 1)%> <%# @ref_desc = "#{@ref_desc_numb}. #{tax_ref.ref_wo_brace}" %> <% end %> <% end %> <% if condition %> <% execution %>
<% elsif condition %> <% execution %> <% elsif taxon_name.emend_author_year %>
<%= print %> <% else %>
<%= print %>
<% end %> <% end %> <% else %> <% if condition %> <%= print %> <% ref_sp_uniq.each_with_index do |ref, i| %> <% if condition %> <% execution %>
<% elsif condition %> <% execution %>
<% end %> <% end %> <% if condition %> <% execution %>
<% elsif condition %> <% execution %>
<% elsif condition %> <% execution %>
<% else %> <% execution %>
<% end %> <% end %> <% end %> <% end %> <% end %>
<% end %>

Kindly suggest me possible way to reduce this kind of junk "if loops".


--
With Regards,
Palani Kannan. K,

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

Ruby on Rails

One of the nice things about Rails Tutorial is that it teaches a
workflow:

http://railstutorial.org/ruby-on-rails-tutorial-book

Also see:

http://blog.weiskotten.com/2009/04/my-git-workflow.html
http://reinh.com/blog/2009/03/02/a-git-workflow-for-agile-teams.html

On Jan 31, 3:10 am, elitalon <elita...@gmail.com> wrote:
> I've been wondering if there is a recommended workflow to follow while developing with Rails.

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

Ruby on Rails

Install mysql package in your system and then copy mysql5.dll and
paste it in the ruby bin folder. And while installing mysql allow it
to edit your environment . You are done. The error wont appear and if
using netbeans.... Then i really cant help coz stay version 3 and
above are not working correctly for many people. Whether these s a bug
or something else m still wondering

On 1/30/11, Selvaraj Subbaian <lists@ruby-forum.com> wrote:
> Jason S. wrote in post #955144:
>> +1 - copying from the instant rails download link to ruby/bin worked for
>> me:
>>
>> Rails 3.0.1
>> Ruby 1.8.7 (and Ruby 1.9.2, works on both)
>> MySQL 5.5 x64
>> Windows 7 x64
>> NetBeans IDE
>>
>> Thanks!
>> Another Jason S.
>
> ohhh.. long lasting issue..now I am facing this issue
>
> Environment..
>
> Rails 3.0.3
> ruby 1.9.2 p136
> mysql Ver 14.14 Distrib 5.1.29-rc, for Win32 (ia32)
> windows vista 32bit
>
> I am getting following error, when I try to do dbconsole..
> Couldn't find database client: mysql, mysql5. Check your $PATH and try
> again.
>
> regards
> Selvaraj
>
> --
> 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+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

--
Sent from my mobile device

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

Ruby on Rails

I am preparing the upgrade of one RoR aplication that used Rails 2.3.8
and where all the translations worked fine. Now I discovered that it
is not the case any more. Everything seems to work fien except the
Error windows header where the interpolation is not recognized.
I'm using Rails 3.0.3, Ruby 1.9.2.
I've just created a simple application, downloaded the latest french
YML file from I18n github and added a simple validation:
[code]
class Client < ActiveRecord::Base
validates :firstname, :lastname, :presence=> true
end
[/code]
Then I modified the 'application.rb' file as follows:
[code]
config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.
{rb,yml}').to_s]
config.i18n.default_locale = :fr
[/code]
Then I tried to save a Client by leaving the mandatory fields empty
and got:
[code]
"Impossible d'enregistrer ce %{model} : %{count} erreurs"
[/code]
as the header of the Errors dialog window. As you see, the
interpolation was taken as it is instead of putting the Model name and
errors number. The rest of validation message was translated
correctly.
Any idea?

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

Ruby on Rails

On Jan 31, 2011, at 3:10 AM, elitalon wrote:
> Some questions come to mind: do you recommend to make a commit after
> applying a migration? Isn't a migration some kind of commit itself?

While in general putting generated artifacts into a repo isn't usually a good idea, I always keep things like the schema in source control, so I do a commit after each migration is run. Personally I've been committing after creating the migration script and then after running it. It might make more sense to treat that as an atomic unit of work and make it a single commit, though.

> I also know that some people begin with the view, then develop the model
> and in the end implement the controller, so what do you recommend?

Start with the cucumber/capybara test. Then create a route, then the simplest controller action and view to make the test pass. If there is any complexity to any of the above, write an rspec test first, then write the code to make it pass. If the controller has too much complexity, either get the tests passing and then refactor to the model, or possibly start with tests for a model object and then call it from the controller. For example, I needed to geocode addresses the other day and after writing the cucumber test, route and controller I immediately added a model object called location to wrap that complexity and rspec tests (with fakeweb and vcr) to ensure it worked as expected.

Best Wishes,
Peter

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

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

Ruby on Rails

On Jan 31, 2011, at 6:27 AM, agathe begault wrote:

> Hello everybody,
>
> I'm trying to allow users to download a file from a server (like a
> Sharepoint one) with a link in my application.
>
> Here is the view:
>
> ...
> <td id="with_icon"><%= link_to image_tag("up.png", :alt =>
> "Download the document", :border => 0, :id => "icon"), d.document_url
> %></td>
> ...
>
> As you can see, i give an url to the link_to method. I would like to
> know if the link is valid or not. I mean if it return really a file or
> not.
>
> I tried some methods like this one :
>
> def remote_file_exist?(url)
> res = Net::HTTP.get_response(URI.parse(URI.encode(url))) rescue
> SocketError
> res
> end
>
> This kind of method return an error for some valide urls and no error
> for some invalide urls.
>
> Have you any idea or suggestion ?

I don't have any code for you, but I do have an idea. Why not set up a
cron/rake task to read all the URLs in your database at some interval,
send a HEAD request to each of them to see if they resolve, and then
mark your database with the result of this test. Keep checking --
don't just write off a bad response, because the server could have
been having a senior moment.

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

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