[Rails] Re: Subdomains

2010-06-17 Thread Franco Catena
You can do that with request.subdomains inside a controller. See
http://api.rubyonrails.org/classes/ActionController/Request.html#M000526

If you want to "change" your primary key (or the key used for search)
try with to_param. See 
http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001840

Regards.

Franco Catena.

On Jun 17, 12:50 pm, David Zhu  wrote:
> hi,
>
> Is there a way for me to have subdomains on my rails project?
>
> For example, if I create a post, i get this 
> URL-http://www.localhost:3000/posts/
> (what ever number)
>
> How can I make the route so that it is  title.localhost:3000/
>
> title is a field of my posts.
>
> Is there a way to do that? OR if that's too complicated, then how do i
> replace the /posts/# with /post.title?
>
> 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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: plugin for running a timer based application

2009-08-28 Thread Franco Catena

Take a look at the Rufus Scheduler http://rufus.rubyforge.org/rufus-scheduler/

I hope this help you, regards.

Franco Catena.

On Aug 27, 4:59 pm, Rukku Bala 
wrote:
> Hi,
> I am trying to achieve the following.. wondering if there is any way to
> achieve this..
>
> Some background:
>
> 1. i have an application where the user can request an specific email to
> be sent at a scheduled time. For e.g. lets say user A wants is
> scheudling the email to be sent for 12:00pm. This is stored in a table
> called "send_notification" where the details is stored.
> 2. Another user B can login and schedule an notification say at 11:45am.
>
> Now, to achieve this..
> Option 1:
> If can have a background task that scans through this table and sends
> the notification. But if i write it as a task that wakes up every minute
> and send the notification, then it has to scan the whole table every
> time. Is it OK ?. In a scaled table it could be an issue.
> Opton 2:
> Maintain a "earliest time" variable in the application. Every time, a
> new notification is created, check if this time is earlier than the
> "earliest time". If so, then cancel the crontab and reschedule based on
> the "earliest time". If not, the crontab will expire and notification
> will be sent and scan the whole table and update the "earliest time".
> This again has the flaw of scanning the entire table.
>
> Option 3:
> an efficient option is to maintain a heap timer tree based on "shcedule
> time". Then the top node timer expires, the notification will be sent.
> This would require no scanning of table but maintaining the heap timer.
> Is a there a plugin for this ?.
>
> How does typcially achieve such a thing.
>
> Thanks.
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Postgres defaults to ID DESC, MySQL defaults to ID ASC

2009-08-19 Thread Franco Catena

(My point of view) Order the result by ID is also a bad idea, if you
switch to another ID schema (for example UUID, descending sequence,
etc.) you must rewrite a lot of code. The ID is something the
application must not "know", order for example by name, by a
created_at field (and that have more sense if you want "the last
created user").

Regards.

Franco Catena.

On Aug 18, 9:01 pm, Ben Johnson 
wrote:
> I just switched to Postgres and some of my tests are failing. It seems
> that Postgres defaults by ordering data by ID DESC, whereas MySQL
> defaults to ordering by ID ASC.
>
> What is the best practice for handling this? Is there a setting in
> Postgres you can change? Should I be explicitly specifying the order of
> my data in my queries?
>
> In various places throughout my application I am doing things like:
>
> User.first
>
> This obviously is not good with the order of the data is not consistent.
> I also feel like the first User should return the first user, not the
> last one created.
>
> What do you think?
> --
> 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: About rails_cron this plugin

2009-07-24 Thread Franco Catena

You can also take a look at http://rufus.rubyforge.org/rufus-scheduler/,
works great for me.

Regards.

Franco Catena.

On Jul 23, 10:50 pm, HeChian Hsu  wrote:
> Do anyone knows where can I to download it?
> Or anyone can give me an advice for a new plugin like this one?
>
> Thanks!
>
> HeChian Hsu
> hechian...@gmail.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to Disable Pluralization

2009-07-22 Thread Franco Catena

I also agree with that, I want to make my point cleaner. English is
not my mother language (if you don't figure it out yet), and
programming in Rails is often a pleasure, but if you want to program
in Spanish for example, the pluralization don't work. For example the
plural of Ciudad (City) is Ciudades, but is pluralized as Ciudads
(awful). I asume that the question was for one problem like this, i
don't "support" not follow the conventions either.

Regards.

Franco Catena.

On Jul 20, 2:55 pm, Rick DeNatale  wrote:
> On Sat, Jul 18, 2009 at 3:24 AM, harun wrote:
>
> > Hi,
>
> > First, I am new at Ruby on Rails. When using scaffolding feature,
> > rails pluralize some automatically generated files' names, like
> > controller names, view names and helper names. What I want is to
> > disable this pluralization. For example, I want the contoller name of
> > model 'Post' to be 'post_controller.rb' instead of
> > 'posts_controller.rb'.
>
> If you want to gain any proficiency with Rails, I'd urge you to resist
> the instinct to do things like this, and go with the flow.
>
> A lot of Rails is following the frameworks conventions, and
> pluralization is one of those.  If you do you'll find things much
> easier in the long run.
>
> If you don't you'll find yourself working much too hard in the long run.
>
> --
> 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: How to Disable Pluralization

2009-07-20 Thread Franco Catena

You can rewrite the inflections using
ActiveSupport::Inflector.inflections (http://api.rubyonrails.org/
classes/ActiveSupport/Inflector/Inflections.html) and do something
like mapping the plural of all words to the same word.

Regards.

Franco Catena.

On Jul 18, 4:24 am, harun  wrote:
> Hi,
>
> First, I am new at Ruby on Rails. When using scaffolding feature,
> rails pluralize some automatically generated files' names, like
> controller names, view names and helper names. What I want is to
> disable this pluralization. For example, I want the contoller name of
> model 'Post' to be 'post_controller.rb' instead of
> 'posts_controller.rb'.
>
> 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: Time calculate method in rails

2009-07-16 Thread Franco Catena

You also can use the DateHelper (http://api.rubyonrails.org/classes/
ActionView/Helpers/DateHelper.html). Always the Rails API is the best
place to start.

Regards.

Franco Catena.

On Jul 16, 1:22 am, Valentino Lun 
wrote:
> Dear all
>
> Is there any existing function in rails to calculate time? I have google
> it but no information found..
>
> For example
> a = "2009-07-16 12:34".to_time
> b = "2009-07-16 12:04".to_time
> some_method(a,b) return "30 mins ago"
>
> c = "2009-07-16 12:34".to_time
> d = "2009-07-12 09:09".to_time
> some_method(c,d) return "4 days ago"
>
> If not, I will write it by my own. But it can save my time if there is
> existing method to do so...
>
> Many thanks
> Valentino
> --
> 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 time triggered actions

2009-07-15 Thread Franco Catena

Take a look at Rufus Scheduler (http://rufus.rubyforge.org/rufus-
scheduler/) is working great for me, and is not plataform dependent.

Regards.

Franco Catena.

On Jul 15, 5:29 am, Enzo Rivello 
wrote:
> Is there a way to make some method to act on a specific time?
>
> Right now, i managed to bypass this problem by attaching this method to
> the login factor of the site (everytime an admin log in the site, also
> this method is called) ,  but there is a more direct and time related
> way?
> --
> 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: Help with loading data with sequential id

2009-07-13 Thread Franco Catena

I suppose you want use the omap YAML type. Read about it in
http://api.rubyonrails.org/classes/Fixtures.html and in
http://yaml.org/type/omap.html.

Regards.

Franco Catena.

On Jul 13, 12:34 pm, khagimoto  wrote:
> Hello,
>
> I'm trying to load data into my mysql table using the following:
>
>   load_codes_data.rb 
> require 'active_record/fixtures'
> class LoadCodesData < ActiveRecord::Migration
>   def self.up
>     down
>     directory = File.join(File.dirname("MY_DIR_NAME"), "data")
>     Fixtures.create_fixtures(directory, "codes")
>   end
>
>   def self.down
>     Code.delete_all
>   end
> end
> ==
>
> and here's the yaml file:
>
> === codes.yml ===
> I:
>   seq: 1
>   cat: source
>   description: Member
> II:
>   seq: 2
>   cat: source
>   description: Friends or Family
> III:
>   seq: 3
>   cat: source
>   description: Book
> IV:
>   seq: 4
>   cat: source
>   description: Search Engine
> V:
>   seq: 5
>   cat: source
>   description: Magazine
> VI:
>   seq: 6
>   cat: source
>   description: Other
> ...
> ...
> ==
>
> Here's my question.
> Codes table has the three fields you see in the yaml file and a unique
> id field that gets populated automatically and gets assigned a random
> non-sequential numbers.  I would like for it to get sequential ids
> assigned.  I've searched for a while, but haven't come across a
> solution.. Can anyone help?
>
> Thanks,
> Kumi
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Nested Forms

2009-07-01 Thread Franco Catena

The account data must be in :user => {:account_attributes => {...}} if
you want auto save it.

You can read about it in the documentation of
ActiveRecord::NestedAttributes::ClassMethods (see fields_for in
ActionView::Helpers::FormHelper too).

Regards.

Franco Catena.

On Jul 1, 1:22 pm, Erwin  wrote:
> I am using a nested form  ( User has_one Account  .. to hold profile
> data)  to UPDATE my user/account data
>
> User model
>  has_one :account
>  accepts_nested_attributes_for :account, :allow_destroy => true
>
> Account model
> belongs_to :user
>
> ---
> my form seems to work fine,  I can see in the console, the @user
> attributes and  the account attribute in the hash
>  "password"=>"", account"=>{"city"=>"", "zip"=>"",
> "country"=>"BE", "street_address"=>"", ...}...
>
> when I debug in the console,
> @user.attributes = params[:user]
> @user.valid? => true       # OK no errors
> @user.attributes = params[:account]
> @account.valid? => false  # OK , name is blank...
>
> but if I debug my :edit action,
>  if @user.update_attributes(params[:user])
> I get true.  which seems to mean that the account errors are not
> tracked ? according to the doc it should be false ...
>
> where am I wrong ?
>
> additional Question :  when errors , how should I display the them
> when they are related to the user.account
> should I use �...@user and @account and :
>  error_message_on @account, :first_name,
>
> or only @user and
>  error_message_on @user.account, :first_name,
>
> thanks for your recommandations
>
> erwin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to disable form elements under any div ????

2009-06-24 Thread Franco Catena

If you are using prototype, you can get (for example) all the divs
with the $$ function and then disable the form elements, see
http://www.prototypejs.org/api/utility/dollar-dollar.

Regards.

Franco Catena.

On Jun 24, 10:51 am, Sandip Ransing  wrote:
> Hello All,
> how do i disable child form elements of any div [ html obj ], so that they
> will not get posted.
> Is there any other way, to toggle form elements while form post ??
>
> > ~~~
>
> 
>
> 
>
> form elements
>
> 
>
> > 
>
> form elements
>
> 
>
> 
>
> ~~~
>
> Sandip R~
>
> --
> Ruby on Rails 
> Developerhttp://sandip.sosblog.comhttp://funonrails.wordpress.comwww.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] Re: pdf-writer background

2009-06-13 Thread Franco Catena

You can acomplish that with "loose content objects", see "Repeating
Elements" in the PDF::Writer manual.

Regards.

Franco Catena.

On Jun 13, 7:34 am, blueomega  wrote:
> So i am exporting data to pdf with pdf-writer, no problems here.
>
> I am using the default white page as background, but i have a document
> template(in many formats), and i would like to use it as default
> background.
>
> Is there a way?
>
> Regards
> Celso Costa
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Export to pdf (graph output)

2009-06-08 Thread Franco Catena

You can do it inside the PDF, this would make a lighter file, and a
vector graph, wich behaves nice with zoom and print. Inside
PDF::Writer's Manual (http://ruby-pdf.rubyforge.org/pdf-writer/) you
have a "Graphics" part, there are good examples.

Regards.

Franco Catena.

On Jun 8, 5:33 am, blueomega  wrote:
> So i have tasks, with start time, end time, the usual stuff, and i
> need to export all the info to pdf (description, owner, relations,
> etc)
>
> Export text to pdf shouldn't be a problem, there are many tutorials
> who explain it
>
> I also need to export a gant chart (need some way to make a screenshot
> from the gantt i have, or make it from the data). making it from data
> would be perfect, some eye candy, would also be good.
>
> Graphviz was what come to mind to do it, is it the best? should i use
> an alternative(something to make charts).
>
> So what gems should i use, do you know a tutorials who implements
> similar stuff?
>
> Cumps
> Celso Costa
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Send a array of objects from a view

2009-06-05 Thread Franco Catena

The best way (for me) is using nested attributes (http://
api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/
ClassMethods.html). You can look a very complete example of usage in:
http://github.com/alloy/complex-form-examples/tree/master and in
http://github.com/soldieron/jquery-nested-forms/tree/master

Regards.

Franco Catena.

On 5 jun, 13:49, Jose Ernesto Suarez  wrote:
> Hi everyone.
>
> I´m working on application that has a "has_and_belongs_to_many" betwen
> two models: "expedientes" and "documentos".
> When I´m on the console, I need to pass a Expedientes Array to
> documentos, otherwise I get a ActiveRecord::AssociationTypeMismatch
> exception.
>
> Example:>> d=Documento.new
>
> => #> d.expedientes=[1]
>
> ActiveRecord::AssociationTypeMismatch: Expediente(#18729340) expected,
> got Fixnum(#108610)
>         ...>> d.expedientes="1"
>
> ActiveRecord::AssociationTypeMismatch: Expediente(#18729340) expected,
> got String(#113650)
> ...>> d.expedientes=Expediente.find("1")
>
> NoMethodError: undefined method `each' for #
> ...>> d.expedientes=[Expediente.find("1")]
>
> => [#
> How must I made this relationship from the view?
> I´ve mading a Form.hidden_field from the view "new" with the name
> "expedientes" and the value of the expediente.id of the
> relationship,but seems incorrect.
>
> What´s the best way to do that?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Counting up in 5's or something similar.

2009-06-05 Thread Franco Catena

You probably talk about the step function (http://www.ruby-doc.org/
core/classes/Numeric.src/M000189.html). Always look first the Ruby
API.

Regards.

Franco Catena.

On Jun 5, 6:04 pm, "Ruby on Rails: Talk" 
wrote:
> Hi
>
> I'm sure I've read somewhere that you can count up in 'jumps' using
> ruby?
>
> I've got two times and I want to basically go up in 15 minute jumps
> without using the whole for loop thing.
>
> Any helpful ideas? All my ruby books are in storage and I can't find
> anything on google ...but then I'm not sure what I'm looking for!
>
> Thanks in advance.
>
> Code:
>
> <%- (@info[0][1].. @info[0][2]). do %>
>
> Darren
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: using attachment fu in masse

2009-06-01 Thread Franco Catena

You can try with the example in the attachment_fu home (http://
github.com/technoweenie/attachment_fu/tree/master):

i.uploaded_data = ActionController::TestUploadedFile.new(file_path,
mimetype)

Regards.

Franco Catena.

On Jun 1, 6:23 am, holden  wrote:
> I tried using ActionController::UploadedStringIO.new( data )
>
> and it does create the files... but the images don't work.
>
> Is data supposed to be the filepath?  ie. photos/joe.jpg ?
>
> I also found an example of exactly what I want to do in the Practical
> Rails Plugins book, but which is outdated using "temp_data ="  It
> looks simple and perfect, what am I missing?
>
> http://books.google.com/books?id=c1L4IzmUzicC&pg=PA49&lpg=PA49&dq=att...
>
> On May 31, 11:22 pm, Maurício Linhares 
> wrote:
>
> > Here's how I'm doing it:
>
> >         file = ActionController::UploadedStringIO.new( data ) #this is
> > the real data
> >         file.instance_variable_set( '@original_filename',
> > "#{rand(1000)}_#{filename}" )
> >         file.content_type = i.content_type
>
> >         i.uploaded_data=( file )
> >         i.save!
>
> > -
> > Maurício Linhareshttp://alinhavado.wordpress.com/(pt-br) 
> > |http://blog.codevader.com/(en)
>
> > On Sun, May 31, 2009 at 5:52 PM, holden  wrote:
>
> > > Something like this almost work...
>
> > > Discussion.new
> > > (:name=>"test2", :location_id=>"1036", :image_attributes=>
> > > [{ :uploaded_data=> File.new("/Users/holden/Desktop/pictures/
> > > LionsFW.jpg") }], :website=>"testdsfdf", :geo=>"", :phone=>"test", 
> > > :blurb=>"testdsfsdfsdf", :address=>"test", :hwID=>"test", 
> > > :email=>"t...@aol.com")
>
> > > undefined method `[]' for # > > LionsFW.jpg
>
> > > On May 31, 6:36 pm, holden  wrote:
> > >> I'm trying to use attachment fu to add a large number of images at
> > >> once using a script but i can't even get it to add an image from the
> > >> console... the other documentation i've found no longer seems to work.
>
> > >> Something like this doesn't work properly
>
> > >> c = Image.new
> > >> c.content_type = 'image/jpeg'
> > >> c.filename = 'test.jpg'
> > >> c.discussion_id = 7330
> > >> c.uploaded_data = File.open('/Users/holden/Desktop/pictures/
> > >> LionsFW.jpg')
> > >> c.save
>
> > >> It does save.. but the file doesn't get populated.
>
> > >> All the previous documentatio circa 2007 says :temp_file but this is
> > >> no longer available to i tried switching it to :uploaded_data, but
> > >> that doesn't seem to work either
>
> > >> also it want's the size and is a required field, but shouldn't this be
> > >> automatically deduced.. providing it doesn't help either...
>
> > >> Any suggestions would be a great help,
>
> > >> Thanks,
>
> > >> holden
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Mi browser no muestra el formato para captura desplegado

2009-05-30 Thread Franco Catena

Jose:

You must use specify to the generator the fields like this:

ruby script/generate scaffold Product name:string description:string

and so on with all the fields in the database. If you want to add one
field in a previously created scaffold you can do it editing the files
in the app/views/products/ directory.

Regards.

Franco Catena.

On May 30, 1:02 pm, Jose Galvan 
wrote:
> Cesar Diaz wrote:
> > It must be a question for spanish list, what do you think?
>
> > Cesar
>
> > ___
> > Gnu/Linux count user #416024
>
> > Skype: cesarstafe
>
> Yes,you are right Cesar, I am sorry, I already left the message in the
> right place,  anyway if you know something about what I am asking for
> please help me, I will appreciate it.
>
> Jose.
> --
> 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: iso-8859-1 no effect in browser

2009-05-26 Thread Franco Catena

Yes, i use it a lot, but in this form:

record.errors.add attr, :invalid # or any other

And then in the config/locales/es.yml

es:
  activerecord:
errors:
  messages:
invalid: "no es válido"

  # Custom for one model
  models:
somemoder:
  attributes:
someattribute:
  invalid: "es inválido"

I never use it in the direct form, always with the I18n package. If
you want a complete example see 
http://github.com/svenfuchs/rails-i18n/tree/master/rails/locale.

Regards.

Franco Catena.

On May 26, 5:00 pm, tivrfoa  wrote:
> thansk Franco.
>
> it works on the view, but not work in the model (at least here)
> did you try to add a message in some model with accent?
>
> On May 26, 2:43 pm, Franco Catena  wrote:
>
> > I create almost only spanish applications, all with Ñ ñ, á é and so
> > on, and use ONLY UTF-8.
>
> > The meta directive  between the head tags does all the magic.
>
> > Regards.
>
> > Franco Catena.
>
> > On May 26, 12:19 pm,tivrfoa wrote:
>
> > > tks! it didn't work in utf-8. if I use está (without the special
> > > character), it display an interrogation symbol (?)
>
> > > Could someone try to use this => :message => 'está incorreto'
> > > in some validation to see if it works?
>
> > > How can I display "está"?
>
> > > tks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: iso-8859-1 no effect in browser

2009-05-26 Thread Franco Catena

I create almost only spanish applications, all with Ñ ñ, á é and so
on, and use ONLY UTF-8.

The meta directive  between the head tags does all the magic.

Regards.

Franco Catena.

On May 26, 12:19 pm, tivrfoa  wrote:
> tks! it didn't work in utf-8. if I use está (without the special
> character), it display an interrogation symbol (?)
>
> Could someone try to use this => :message => 'está incorreto'
> in some validation to see if it works?
>
> How can I display "está"?
>
> tks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: is f.submit in a form_for newer than submit_tag?

2009-05-24 Thread Franco Catena

All the method in the form helper have his "object implicit"
counterpart, for example you can call text_field(object_name, method,
options = {}) or f.text_field(method, options = {}) and the object
used is f.object (the parameter of form_for @something), they produce
exactly the same output.

Regards.

Franco Catena.

On May 24, 6:06 pm, SpringFlowers AutumnMoon  wrote:
> some books or even the rails api uses
>
> form_for ...
>   ...
>   submit_tag ...
> end
>
> and i found that the Rails 2.3.2 Scaffold uses
>
> f.submit "Go"
>
> instead...  and this is not in the rails api doc.  Is this a new
> addition and is it suppose to replace submit_tag?
> --
> 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: habtm association and accepts_nested_attributes_for

2009-05-20 Thread Franco Catena

Try using the ID inside (this works for me):

params = { 'form' => { 'name' => 'paul', 'dni' => '17002034z',
 'projects_attributes' => {
   '1' => { 'id' => '1', 'name' => '', 'cost' =>
'25000' },
   '2' => { 'id' => '2', 'name' => '', 'cost' =>
'3400'

An element with an ID is considered to be updated instead of created.

On May 20, 7:09 am, Gonzalo  wrote:
> hi all,
>
> i have the following models:
>
>   class Developer < ActiveRecord::Base
>     has_and_belongs_to_many :projects
>     accepts_nested_attributes_for :projects
>   end
>
>   class Project < ActiveRecord::Base
>     has_and_belongs_to_many :developers
>     accepts_nested_attributes_for :developers
>   end
>
> the following code:
>
>   params = { 'form' => { 'name' => 'gonzalo', 'dni' => '12876365x',
>                'projects_attributes' => {
>                  'new_01' => { 'name' => 'Sioux', 'cost' => '25000' },
>                  'new_02' => { 'name' => 'Apache', 'cost' =>
> '3400'
>   Developer.create(params['form'])
>
> will create a new Developer and two new Projects and the corresponding
> association between Developer and Projects.
>
> then, I add a new Developer using the same mechanism:
>
>   params = { 'form' => { 'name' => 'paul', 'dni' => '17002034z',
>                  'projects_attributes' => {
>                    '1' => { 'name' => '', 'cost' => '25000' },
>                    '2' => { 'name' => '', 'cost' => '3400'
>   Developer.create(params['form'])
>
> following NestedAttributes documentation... this code should add a new
> Developer (paul) and link it against the two already created Projects
> with ids 1 and 2. Besides, this code should modiify projects names
> from Sioux and Apache to  and  respectively.
>
> the real result is that a new Developer (paul) is added but linked
> against two new Projects ( and )
>
> am I doing something wrong? should i use another approach to face this
> problem? is accept_nested_attributes_for feature compatible with habtm
> associations?
>
> and last... what if i just want to create a new Developer (paul) that
> is associated with the already created Projects with ids 1 and 2? The
> following code won't work:
>
>   params = { 'form' => { 'name' => 'paul', 'dni' => '17002034z',
>                    'projects_attributes' => {
>                      '1' => { },
>                      '2' => { 
>   Developer.create(params['form'])
>
> thanks in advance for your help!
> regards.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Beautiful url

2009-05-20 Thread Franco Catena

My mistake, http://api.rubyonrails.org/classes/ActionController/Routing.html

Regards.

Franco Catena.

On May 20, 3:42 am, "Mr. Bless"  wrote:
> How to have a beautiful url like hulu. For example I like to have a
> url like this to show the movie detail with an id 1 
> ashttp://localhost:3000/movie/detail/1-movie_name
>
> If via a link, i can do this by writing the to_param method in movie
> model like this
>  def to_param
>     "#{id}-#{name}"
>   end
>
> and a like like this
> <%=link_to
> 'Detail', :controller=>'movie',:action=>'detail',:id=>@movie %>
>
> How ever if the someone manually typehttp://localhost:3000/movie/1,
> I still need the url as shown previously.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Beautiful url

2009-05-20 Thread Franco Catena

You can do something like http://localhost:3000/movie/detail/1/movie_name
(with a slash) see more in 
http://api.rubyonrails.org/classes/ActionController/Routing/Helpers.html

Regards.

Franco Catena.

On May 20, 3:42 am, "Mr. Bless"  wrote:
> How to have a beautiful url like hulu. For example I like to have a
> url like this to show the movie detail with an id 1 
> ashttp://localhost:3000/movie/detail/1-movie_name
>
> If via a link, i can do this by writing the to_param method in movie
> model like this
>  def to_param
>     "#{id}-#{name}"
>   end
>
> and a like like this
> <%=link_to
> 'Detail', :controller=>'movie',:action=>'detail',:id=>@movie %>
>
> How ever if the someone manually typehttp://localhost:3000/movie/1,
> I still need the url as shown previously.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Problems with upload using attachment_fu

2009-05-19 Thread Franco Catena

The file field must be named "uploaded_data", try with that.

Regards.

Franco Catena.

On May 19, 12:48 am, Nerdaniel  wrote:
> Hello everyone,
>
> I'm having problems with :html => { :multipart => true } in my edit
> form. It doesn't returns the image in the parameter, so everything
> fails with this errors:
>
> There were problems with the following fields:
>
>     * Size can't be blank
>     * Size is not included in the list
>     * Content type can't be blank
>     * Content type is not included in the list
>     * Filename can't be blank
>
> A friend of mine said that he had this problem in windows and I am in
> a mac 10.5.6. =/
>
> If I put multipart off it gives the same error. Everything I
> implemented was following attachment_fu tutorials all over the net.
> This is my edit:
>
> = error_messages_for :user, :avatar
>
> - form_for(@user, :url => { :action => 'update' }, :html =>
> { :multipart => true }) do |f|
>   = f.label "avatar"
>   %br
>   = f.file_field :avatar
>   %br
>   %br
>   = f.submit "save image!"
>
> Thx!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: date environment.rb

2009-05-17 Thread Franco Catena

You can do this with i18n (Rails >= 2.2) setting up properly the
format in your config/locales (see examples in
http://github.com/svenfuchs/rails-i18n/tree/master/rails/locale) and
then use <%= l(some_date) %>.

Regards.

Franco Catena.

On May 17, 3:21 pm, Herman Müller 
wrote:
> Hi Ruby-Comunity!
>
> I have a problem with date format.
>
> To display the german date format, I put on the end of environment.rb:
>
> ActiveSupport::CoreExtensions::Date::Conversions::DATE_FORMATS.merge!(:default
> => '%d.%m.%Y')
> ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(:default
> => '%d.%m.%Y %H:%M:%S')
>
> In index/show.html.erb datetime is displayed like expected:
>
> 05.06.2009 10:00:00
>
> In edit.html.erb datetime is not displayed in german date format:
>
> <%= f.text_field :valid_from %> --> displays
>
> 2009-05-05 00:00:00
>
> Have somebody a solution?
>
> Thanks ahead!!
>
> Regs
>
> Hermann
> --
> 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: uploading powerpoint file

2009-05-17 Thread Franco Catena

You can do this "by hand" or with a plugin. I recomend the last
option, one that work well (for me) is the attachment_fu plugin
(http://github.com/technoweenie/attachment_fu/tree/master).

Regards.

Franco Catena.

On May 17, 1:11 pm, Ghazaleh Mir 
wrote:
> hi
> i want to put the ability tu upload a powerpoint file in my website
> where can i learn that?
> --
> 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: Encrypt passwords in the database

2009-05-12 Thread Franco Catena

Is the same thing:

require 'digest'

Digest::MD5.hexdigest('password')

You need to know how to read an API, you must use it every day ... The
"always open" are:

http://www.ruby-doc.org/core/ and http://api.rubyonrails.org/

Expend a while figuring it out.

Regards.

Franco Catena.

On May 12, 5:46 pm, Lakridserne  wrote:
> Thanks. I looked at it, but could not understand it. I will use md5
> because I also use it in my PHP-applications, and I can therefore use
> the same data without reset users passwords and so on. Can I do that
> and how?
>
> On 9 Maj, 17:38, Franco Catena  wrote:
>
> > You can use one of the Ruby digest 
> > package:http://www.ruby-doc.org/stdlib/libdoc/digest/rdoc/index.html
>
> > For example, if you want to digest a password with SHA 512:
>
> > require 'digest/sha2'
>
> > Digest::SHA2.hexdigest('password', 512)
>
> > Regards.
>
> > Franco Catena.
>
> > On May 8, 6:18 pm, Lakridserne  wrote:
>
> > > Hi,
>
> > > I know that there is a way to encrypt passwords, but what would be the
> > > easiest?
> > > For example you have 2 functions in php. You use them by calling:
>
> > > fuction("data-to-be-encrypted-here");
>
> > > But is there a similar way in ruby on 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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Encrypt passwords in the database

2009-05-09 Thread Franco Catena

You can use one of the Ruby digest package:
http://www.ruby-doc.org/stdlib/libdoc/digest/rdoc/index.html

For example, if you want to digest a password with SHA 512:

require 'digest/sha2'

Digest::SHA2.hexdigest('password', 512)

Regards.

Franco Catena.

On May 8, 6:18 pm, Lakridserne  wrote:
> Hi,
>
> I know that there is a way to encrypt passwords, but what would be the
> easiest?
> For example you have 2 functions in php. You use them by calling:
>
> fuction("data-to-be-encrypted-here");
>
> But is there a similar way in ruby on 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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: how hidden field

2009-05-06 Thread Franco Catena

Change form.text_field for form.hidden_field, see
http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html
for more options.

Regards.

Franco Catena.

On May 6, 4:16 am, "pleb...@gmail.com"  wrote:
> Dear all,
>
> i wrote script in view like this,
> <% form_for :seq do |form| %>
>      
>       Source Information
>         
>           User ID 
>           <%= form.text_field  :user_id, :value => session
> [:user_id],:size=>10 %>
>         
>    
>  <% end %>
>
> and i want hide this field to user but i want value= session[:user_id]
> to  insert database automatically
> how i do?
> 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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Automatically delete oldest post of a specified tag

2009-04-30 Thread Franco Catena

> The callback would be placed in the post model correct?
Yes.
> And that callback would include code that would find the
> amount of posts in that tag if it exists?
Yes.
> Then how would I use that in the post controller's create
> method?
When you call @post.save in the controller the appropiated callbacks
in the Post model are called, so you don't need a explicit call to a
function or do another thing inside the model.

Regards.

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



[Rails] Re: Automatically delete oldest post of a specified tag

2009-04-29 Thread Franco Catena

You really need to delete the post? With :limit => 20 in your find is
not enought?. If the answer is a double yes, then you should use an
ActiveRecord callback (perhaps after_save
http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html#M002084)

Regards.

Franco Catena.

On Apr 29, 7:12 pm, Victor Vlist 
wrote:
> I have a form that allows a user to create a post with a title, body,
> image and a tag. All fields are required using validates_presence_of and
> has_attached_file in the model.
> Since every post has a tag, there is a page for each tag that has all
> the posts with that tag paginated on it. When this tag (show) view
> reaches a specified limit, I want the oldest post with that tag deleted
> as a new one is created.
>
> This is what I think I have to do: before a post is saved, I have to
> find how many posts exist with that tag, if more than (let's say) 20
> exist, delete the post with the oldest "updated_at" value that belongs
> to that tag.
> In my tags (show) view I use this code to show how many posts for a tag
> exist:
> [code=]<% post.tag_counts.each do |tag| %>
>   Posts for this topic: <%= tag.count %>
> <% end %>[/code]
> When I create a post, this is what is used in my posts_controller
> currently:
> [code=]  def create
>     @post = Post.new(params[:post])
>     respond_to do |format|
>       if @post.save
>         #...@old_post = Post.first
>         #...@old_post.destroy
>         flash[:notice] = "Post successfully created."
>         format.html { redirect_to(:controller => "tags") }
>       else
>         flash.now[:error] = "Error creating post."
>         format.html { render :action => "new" }
>       end
>     end
>   end[/code]
> I use this form to create a post:
> [code=]<% form_for @post, :html => { :multipart => true } do |f| %>
>   <%= f.label :title %>
>   <%= f.text_field :title %>
>
>   <%= f.label 'Image' %>
>   <%= f.file_field :image %>
>
>   <%= f.label :body %>
>   <%= f.text_area :body %>
>
>   <%= f.label 'Topic' %>
>   <%= f.text_field :tag_list %>
>
>   <%= f.submit 'Create' %>
> <% end %>[/code]
> Before each post is created, I need to somehow check how many posts have
> the tag that the user has entered in the form (<%= f.text_field
> :tag_list %>). So if that tag doesn't exist, it should create the post.
> If that tag already exists, it should check how many posts for that tag
> exist and if the amount of posts that belong to it is less than 20,
> create the post, if the amount of posts that belong to that tag equal or
> is greater than 20, it should delete the post with the oldest
> 'updated_at' value (and create the post).
>
> I'm not completely sure but I think I have to add this to the create
> method in my posts controller. Can someone push me in the right
> direction?
> --
> 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: Custom error message

2009-04-28 Thread Franco Catena

You can define a rescue function in your ApplicationController and
then do whatever you want:

def rescue_action(exception)
# Rescue code, redirection, ecc.
end

This function is called if exists, if not Rails shows you the default
one.

Regards.

Franco Catena.

On Apr 28, 10:27 am, Dharmdip Rathod  wrote:
> Hello,
>
> How to get error page redirection when i am get rails conventional
> exception .
>
> Say like, i have error in my controller and rails will give me exception
> and will render me error page but i want custom error page redirection.
>
> Thanks.
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: chmod in rails development

2009-04-28 Thread Franco Catena

I always use 755, only running rake gems:install needs sudo for me.
You can run script/server without sudo. This is MY config, otherwise
the permisions in the develpment environment are not critical.

Regards.

Franco Catena.

On Apr 28, 7:18 am, Milan Dobrota 
wrote:
> What chmod value I am supposed to use for rails app development? Is 777
> a good idea? Or should I use sudo when I run my commands (such as
> script/server)?
> --
> 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: Renaming a file inside a zip

2009-04-27 Thread Franco Catena

There is no method to directly rename a directory, you must use the
rename in every file between the directory like this:

Zip::ZipFile.open('my.zip') do |zipfile|
  zipfile.file.rename 'original_dir/orignal_name.txt', 'new_dir/
original_name.txt'
end

And after that you can remove the original directory.

Regards.

Franco Catena.

On Apr 27, 2:00 pm, elioncho  wrote:
> I copied a wrong code, here it is. As I say before it only works for
> renaming the file not the folder.
>
>     Zip::ZipFile.open('/home/elioncho/Desktop/MyApp.zip'){|zf|
>       parent_folder = zf.get_entry('Test/')
>       file = zf.get_entry('Test/build.yml')
>       parent_folder.name = 'Testing/'
>       file.name = 'Test/builder.yml'
>     }
>
> On Apr 27, 11:58 am, elioncho  wrote:
>
> > Hi Franco,
>
> > Thanks for your reply, but still it ain't working for. I need to
> > rename a folder not a file. It works fine for file but not for
> > folders. I tried this and it correctly renamed the file build.yml to
> > builder.yml, BUT the folder wasn't rename, instead it created a new
> > folder in the same level of the one I wanted to rename. Any clues?
>
> >     Zip::ZipFile.open('/home/elioncho/Desktop/MyApp.zip'){|zf|
> >       parent_folder = zf.get_entry('Test/')
> >       file = zf.get_entry('Prueba/build.yml')
> >       parent_folder.name = 'Prueba/testing/'
> >       file.name = 'Prueba/builder.yml'
> >     }
>
> > On Apr 27, 11:39 am, Franco Catena  wrote:
>
> > > You must require 'zip/zipfilesystem' and
>
> > > Zip::ZipFile.open('my.zip') do |zipfile|
> > >   zipfile.file.rename 'orignal_name.txt', 'new_name.txt'
> > > end
>
> > > And this is it, for more information see the Zip::ZipFileSystem class
> > > documentation.
>
> > > Regards.
>
> > > Franco Catena.
>
> > > On Apr 27, 12:12 pm, elioncho  wrote:
>
> > > > Hello,
>
> > > > Can anyone help me or give me any clue on how to rename a file (or
> > > > folder) inside a zip file without having to unzip it first. I'm trying
> > > > to do this using the rubyzip gem without luck.
>
> > > > Thanks,
>
> > > > Elías
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Renaming a file inside a zip

2009-04-27 Thread Franco Catena

You must require 'zip/zipfilesystem' and

Zip::ZipFile.open('my.zip') do |zipfile|
  zipfile.file.rename 'orignal_name.txt', 'new_name.txt'
end

And this is it, for more information see the Zip::ZipFileSystem class
documentation.

Regards.

Franco Catena.

On Apr 27, 12:12 pm, elioncho  wrote:
> Hello,
>
> Can anyone help me or give me any clue on how to rename a file (or
> folder) inside a zip file without having to unzip it first. I'm trying
> to do this using the rubyzip gem without luck.
>
> Thanks,
>
> Elías
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Listing of Category error

2009-04-24 Thread Franco Catena

You can read the Agile Web Development With Rails (http://
www.pragprog.com/titles/rails3), is a very good book. It explains step
by step the framework and a very common (but usefull) workflow.

Regards.

Franco Catena.

On Apr 24, 3:20 pm, haneef5k  wrote:
> Hi,
>
> Im new to Ror,  i want to do some userful website can u tell me ur
> advice and wat steps i should to take basically in Ruby on Rails..??
> then im trying to understand tat ( models, controller, action ) it
> confusssed..
> pls help me..
>
> hanee...@gmail.com
>
> On Apr 24, 9:12 pm, Franco Catena  wrote:
>
> > You must declare a has_many :categories in the Post model and a
> > belongs_to :post in the Category model (if the category table has a
> > post_id column, if not keep reading). If you don't do that, you need
> > to create a categories_posts table with two columns: category_id and a
> > post_id.
>
> > Regards.
>
> > Franco Catena.
>
> > On Apr 24, 11:51 am, haneef5k  wrote:
>
> > > Im trying to see posts index page, In tat im showing category list, im
> > > using collect method it show error..
>
> > > ActiveRecord::StatementInvalid in Posts#index
> > > Showing app/views/posts/index.html.erb where line #19 raised:
>
> > > Mysql::Error: Unknown column 'categories_posts.category_id' in 'on
> > > clause': SELECT `categories`.* FROM `categories`  INNER JOIN
> > > `categories_posts` ON `categories`.id =
> > > `categories_posts`.category_id    WHERE ((`categories_posts`.post_id =
> > > 1))
>
> > > Extracted source (around line #19):
>
> > > 16:     <%= post.created_at.strftime('%m/%d/%y %I:%m %p') %>
> > > 17:     <%= h(post.title) %>
> > > 18:     <%= h(post.author.display_name) if post.author %>
> > > 19:     <%= post.categories.collect {|cat| [cat.name] }.join(",")
> > > %>
> > > 20:     <%= h(post.status) %>
> > > 21:     <%= post.comments_count %>
>
> > > pls help me,, im new to RoR..??- Hide quoted text -
>
> > - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Listing of Category error

2009-04-24 Thread Franco Catena

You must declare a has_many :categories in the Post model and a
belongs_to :post in the Category model (if the category table has a
post_id column, if not keep reading). If you don't do that, you need
to create a categories_posts table with two columns: category_id and a
post_id.

Regards.

Franco Catena.

On Apr 24, 11:51 am, haneef5k  wrote:
> Im trying to see posts index page, In tat im showing category list, im
> using collect method it show error..
>
> ActiveRecord::StatementInvalid in Posts#index
> Showing app/views/posts/index.html.erb where line #19 raised:
>
> Mysql::Error: Unknown column 'categories_posts.category_id' in 'on
> clause': SELECT `categories`.* FROM `categories`  INNER JOIN
> `categories_posts` ON `categories`.id =
> `categories_posts`.category_id    WHERE ((`categories_posts`.post_id =
> 1))
>
> Extracted source (around line #19):
>
> 16:     <%= post.created_at.strftime('%m/%d/%y %I:%m %p') %>
> 17:     <%= h(post.title) %>
> 18:     <%= h(post.author.display_name) if post.author %>
> 19:     <%= post.categories.collect {|cat| [cat.name] }.join(",")
> %>
> 20:     <%= h(post.status) %>
> 21:     <%= post.comments_count %>
>
> pls help me,, im new to RoR..??
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Translation inside models?

2009-04-23 Thread Franco Catena

Inside a model is used like this:

I18n.t(:username_in_use)

You can also put it in the translation yml like this:

es:
  activerecord:
errors:
  messages:
taken: "ya está en uso"

There are more examples in: 
http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale

Regards.

Franco Catena.

On Apr 23, 8:43 am, Heinz Strunk 
wrote:
> Hey people,
>
> I'm having a problem translating messages inside a model, e.g. I used to
> have it like this:
>
> validates_uniqueness_of :username, :message => "Username in use already"
>
> which worked fine but now I wanna internationalize my application and
> thought it'd work like everywhere else in my application and I did
> following:
>
> validates_uniqueness_of :username, :message => (t :username_in_use)
>
> and I get: `method_missing': undefined method `t'
>
> Is it not possible to translate text inside a model? If it is... how do
> I do it the right way?
> --
> 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: Can you run a find on an existing hash?

2009-04-23 Thread Franco Catena

In the Enumerable's find_all method will be:

@products.find_all { |product| product.category_id = 2 }

This method returns an array, the find method returns only the first
match. This approach is not the best if you have a lot of products, in
that case you will use the ActiveRecord's find and let the database do
this work in a more efficient way.

Regards.

Franco Catena.

On Apr 23, 2:10 am, Robert Scott 
wrote:
> This is probably a basic question, but I was wondering if / how it's
> possible to run a find on an existing hash.
>
> For instance:
>
> 1. I need to pull all products in the database for a simple list:
> @products = Products.find(:all)
>
> 2. At a separate portion of the page, I want to display products that
> are in, say, category 5.
>
> From scratch, I could run...
> @new_products = Products.find(:all, :conditions => {:category_id => 5})
>
> Although, I thought you could also do
>
> @new_products = @products.find(:all, :conditions => {:category_id = 2})
>
> My query has been returning a wrong number of arguments (2 for 1), so I
> wasn't sure if I was headed on the right track.
> --
> 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: default values for new table entry

2009-04-22 Thread Franco Catena

You can do this in the controller:

@foo = Foo.new(:parameter_name => true)

And then this in the view:

form_for(@foo) do |f|

f.check_box :parameter_name

Regards.

Franco Catena.

On Apr 22, 5:24 pm, big poppa  wrote:
> All,
>
> I would like a new record that is created with the new.html.erb page
> to always populate a specific variable with a default value.
>
> The simplest way would be to have a check_box that defaults to checked
> when the page is loaded, but this seems to be tricky.
>
> Current code looks something like
> form_for(@foo) do |f|
> ...
> check_box(:f, :this_should_always_be_yes_from_this_form, {}, 1, 0)
>
> 1. Can I set this value automatically?
> 2. Can I get the check box to default to "yes"?
>
> Thanks,
> Ben
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: attachment_fu giving problem on production

2009-04-21 Thread Franco Catena

Sorry, I reply my reply because I omit the "original image is saved"
part. Anyway, take a look at the log/production.log and tell us what
you see.

Regards.

Franco Catena.

On Apr 21, 9:08 pm, Franco Catena  wrote:
> Can be a filesystem permision problem. Can you see the log/
> production.log file and post the relevant section?
>
> Regards.
>
> Franco Catena.
>
> On Apr 21, 3:37 pm, Abhishek shukla  wrote:
>
> > Hello friends,
> > I have configured attachment_f. It's working fine on Local(development)
> > system but giving problem on production. Basically on production the
> > attachment_fu is not able to generate thumbnail image it saving the original
> > size image. Below is the configuration.
>
> >   has_attachment :content_type => :image,
> >                  :storage => :file_system,
> >                  :max_size => 500.kilobytes,
> >                  :thumbnails => {:thumb => '170x60>'},
> >                  :processor => 'Rmagick',
> >                  :path_prefix => 'public/store_images'
>
> > Is any idea what can be an issue?
>
> > Regards
> > Abhi
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: attachment_fu giving problem on production

2009-04-21 Thread Franco Catena

Can be a filesystem permision problem. Can you see the log/
production.log file and post the relevant section?

Regards.

Franco Catena.

On Apr 21, 3:37 pm, Abhishek shukla  wrote:
> Hello friends,
> I have configured attachment_f. It's working fine on Local(development)
> system but giving problem on production. Basically on production the
> attachment_fu is not able to generate thumbnail image it saving the original
> size image. Below is the configuration.
>
>   has_attachment :content_type => :image,
>                  :storage => :file_system,
>                  :max_size => 500.kilobytes,
>                  :thumbnails => {:thumb => '170x60>'},
>                  :processor => 'Rmagick',
>                  :path_prefix => 'public/store_images'
>
> Is any idea what can be an issue?
>
> Regards
> Abhi
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---