[Rails] file_field and rails3

2010-11-29 Thread eugenio
Hello everybody, i need to manage file uploads with a new rails application. I proceded as i did with rails2 - declared the form as multipart <%= form_for(@photo, :html => {:multipart => true}) do |f| %> - and added the file_field tag <%= f.label :uploaded_data %> <%= f.file_field :uploade

[Rails] Re: Acts_as_ferret is not indexing either locally or remote

2010-11-27 Thread eugenio
I think you have to specify which fields ferret will index. Take a look at: https://github.com/jkraemer/acts_as_ferret (under "Usage"). I got a lot of problems with ferret under production, you may consider switching to sphinx/thinking sphinx. On 27 Nov, 07:00, Arun Kumar wrote: > Hi All, >   I w

[Rails] attachment in the database with thumbnail generation - rails3

2010-10-21 Thread eugenio
What is the best solution for handling blob database storage with rails3? I used attachment_fu before, but it doesn't seem to work well with rails3. Anyone got it working? paperclip seems nice, but i need database storage for backups and security. -- You received this message because you are subs

[Rails] passenger and apache: worker or prefork

2010-05-14 Thread eugenio
i'm going to install apache and passenger on a intel atom dual (dual core). is it better to install apache-worker or apache-prefork? -- You received 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...@goo

[Rails] migration and myisam

2010-05-14 Thread eugenio
do rails migrations use mysql default storage engine or do they force using innodb? what happen if innodb is disabled on the mysql server? i want to use only myisam, do i need to change something in the migrations? -- You received this message because you are subscribed to the Google Groups "Ruby

[Rails] Re: convert accentend chars to their base

2010-05-10 Thread eugenio
your code convert only that sequence of character. what i need is to convert those accented char in every word. so "città" => "citta", "caffè" => "caffe" and so on maybe some regexp? On 10 Mag, 12:50, Peter Hickman wrote: > Well something like > > char_from = "àéìòù" > char_to   = "aeiou" > > x =

[Rails] convert accentend chars to their base

2010-05-10 Thread eugenio
is there a good way to convert "special" accented chars to their base chars? as an example i want "àéìòù" => "aeiou" i'm using several gsub now "àèìòù".gsub("à","a").gsub("è","e").gsub("ì","i")... it works but i wonder if there is something better than this. -- You received this message because y

[Rails] Re: how to save text

2010-04-28 Thread eugenio
On 28 Apr, 08:49, nirosh wrote: > thank you for the reply. already the data type is text.but that won't > work for me if what you want is to save the style of the text (like bold, italic, font size, etc.) you either need to use some html directly (quite ugly for your users) or an "improved" text

[Rails] keeping track of who did what

2010-03-28 Thread eugenio
hello everybody. i need to log "who did what" on some models. i was reading recipe 59 of rails recipes and i created something like that: class LogSweeper < ActionController::Caching::Sweeper observe :model1, :model2, :model3, :model4, :model5, ... after_save(model) save_log(model, "save"

[Rails] Re: method_missing

2010-03-18 Thread eugenio
it seems to work now. On 18 Mar, 11:23, eugenio wrote: > i'm using method_missing to implement a simple metaprogramming that > checks for account rights. > > in Account << ActiveRecord::Base i defined: > > def method_missing(m, a = {}) >   if m.to_s =~ /^has_r

[Rails] method_missing

2010-03-18 Thread eugenio
i'm using method_missing to implement a simple metaprogramming that checks for account rights. in Account << ActiveRecord::Base i defined: def method_missing(m, a = {}) if m.to_s =~ /^has_right_(.*)$/ ... calls another method passing $1 parameter end end it seems to override some of the ac

[Rails] Re: combine two has_and_belongs_to_many

2010-03-15 Thread eugenio
On 15 Mar, 13:51, Michael Pavling wrote: > you can add a "rights" method to your user that collects up all the > rights for all of the User's roles: > > def rights >   roles.collect { |role| role.rights }.flatten.uniq > end > > This gives you a starting point... you can memoize that method if y

[Rails] combine two has_and_belongs_to_many

2010-03-15 Thread eugenio
a "User" has_and_belongs_to_many "Roles" a "Role" has_and_belongs_to_many "Rights" how can i relate Users and Rights? i would like something like @user.rights i know it can be done via SQL, but i don't know if there is a more rails-way to do this. any suggestion? thanks. -- You received this mes

[Rails] Re: validation and STI

2010-03-08 Thread eugenio
On 8 Mar, 22:14, Jay P wrote: > What version of rails are you using? i'm using rails 2.3.5 i tried to insert some User models with the web interface and the validation works there. maybe it's only an sql cache issue. > > I just read "This seems to be a regression issue > on Rails 2.3, works fin

[Rails] validation and STI

2010-03-08 Thread eugenio
i got a problem with validation and sti class Account < ActiveRecord::Base validates_uniqueness_of :field1 ... end User < Account ... end i created a few User models in the bootstrap file and i noticed that the validation does not work. Do you know why? -- You received this message beca

[Rails] testing a domain driven application

2010-03-04 Thread eugenio
in the application i'm working on i modify the view_path according to the value of request.domain. it seems to work, but my functional test fail. how can i specify the request.domain value in the testing environment? -- You received this message because you are subscribed to the Google Groups "Ru

[Rails] Re: text_field instead of a collection_select

2010-02-10 Thread eugenio
i tried the plugin you suggested, which seems exactly what i'm looking for. but i got stuck: my user model has this line belongs_to :cap_residenza, :class_name => 'Cap' and i added accepts_nested_reference_and_attributes_for :cap_residenza, :codice, :required => true in the form view i added

[Rails] text_field instead of a collection_select

2010-01-29 Thread eugenio
one of my model belongs_to another (zip codes). i would like to let the user insert the zip code in a text field instead of the select menu generated by the collection_select. No new zip code should be created and the code should be validated (it should be in the list of valid code). How can this b

[Rails] around_filter and with_scope

2010-01-27 Thread eugenio
i got two controller (with restful actions) where my code is quite ugly and not very dry. every action looks quite like this: if @logged_user.has_role?("admin") User.find(params[:id) else @logged_user.group.user.find(params[:id]) this is a security check that enforce a simple spec: normal user

[Rails] same controller and database, different views based on domain name

2010-01-24 Thread eugenio
what is the easiest way to achieve that result? i would like to keep controllers and models the same for all the "applications", which, in fact, are the same. They only appear different (the views, the css, and a parameter of the query that will be sent to the database). I could separate the rails

[Rails] attachment_fu, how to regenerate thumbnails

2009-11-26 Thread eugenio
i'm using this plugin for files and images uploads. it has a very useful feature that generate thumbnails of every uploaded image, based on the geometry given in the model definition. now i want to change the size of one of the thumbnail: how can i re- generate them for the already saved image? i

[Rails] Re: unsigned int in migration

2009-11-23 Thread eugenio
you are right. but because they're use the same memory i thought it would be correct to let the application to use all of them if needed. i think it's just a mysql habit i got. thanks. On 23 Nov, 17:13, Matt Jones wrote: > On Nov 22, 11:44 am, eugenio wrote: > > > i not

[Rails] Re: Soft Deletes - Let's try this again...

2009-11-23 Thread eugenio
i simply use the destroy action and a date column for that. On 23 Nov, 16:48, Mike Gehard wrote: > Hello all, > > It seems that my first posting got into some sort of limbo so > apologies for the repost... > > I am wondering how people here are handling soft deletes in Rails. > I've need a couple

[Rails] Re: Beginner's challenge

2009-11-23 Thread eugenio
what challenges? if you didn't change things you are in development environment and you are using sqlite. so run 'rake db:migrate' and it will create your database. if it doesn't check if you installed the gem sqlite3-ruby. if you still got an error, PASTE it, maybe someone could help you. On 23

[Rails] mysql replication and rails

2009-11-23 Thread eugenio
i would like to use some kind of replication (master -> slave or, better, master <-> master) to provide better performance and fail- over. as i read, multi-master replication in mysql is quite problematic: i'm talking about duplicate key problem. so i was searching about plugins that make rails aw

[Rails] unsigned int in migration

2009-11-22 Thread eugenio
i noticed that rails create signed int(11) for id fields (i'm using mysql, i don't know if it acts like this with different databases). i think that unsigned is better for primary keys (and foreign keys). Is there an easy way to indicate that in a migration? -- You received this message because y

[Rails] Re: memcached and fragment caching

2009-11-19 Thread eugenio
On 19 Nov, 23:41, Philip Hallstrom wrote: > compression?  Not sure what you mean.  Memcached is very fast.  Most   > people use it because their db isn't fast enough or to lighten the   > load... it is an memcached options. but i'm not so convinced about it e.g.: memcache_options = { :compress

[Rails] Re: Terminating a request early with throw or raise

2009-11-19 Thread eugenio
i don't know if i understand what you need, but i usually put various checks on a befor_filter. if conditions are not met you will simply return false and the execution stops. On 19 Nov, 23:39, candlerb wrote: > Is there a standard way in Rails of terminating a request early with > throw or raise

[Rails] memcached and fragment caching

2009-11-19 Thread eugenio
i'm reading about memcached, which i never used before. it seems really interesting, but i found discording informations about it (and rails). a) what is a reasonable memory usage for memcached? i read on some sites ~1gb while the default on my ubuntu server is only 64mb. i understand it's applica

[Rails] Re: Displaying information from one model on all views in an application

2009-11-16 Thread eugenio
you can use a before_filter in the application controller. in the method called by before_filter fetch the data you want from the model and store the result in an instance variable, e.g. @message create a partial that use this @message variable and insert it in your application layout. On 16 Nov,

[Rails] Re: Routes with more than 1 param between slashes...

2009-11-16 Thread eugenio
it should, i used something like that (i mean with '-') did you keep the numeric id at the beginning of the to_params? you can search for Document.find(params[:id]) at usual because params [:id] is passed through to_i "43-en-2008-04.pdf".to_i == 43 On 16 Nov, 21:08, Wagner wrote: > I tried this

[Rails] Re: Routes with more than 1 param between slashes...

2009-11-16 Thread eugenio
if the only thing you need is a nicer url you can override the to_params method in the model. something like: def to_params "#{id}-#{language}-#{year}-#{month}" end --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ru

[Rails] named_scope and duplicate sql conditions

2009-11-16 Thread eugenio
suppose we got two models: category and article. category has_many articles, article belongs_to category article has a named_scope defined by named_scope :online, :conditions => {:state => 2} in the controller i want to search for online articles that belongs to a given category. i tried this qu

[Rails] Re: atomic INSERT or UPDATE with activerecord

2009-11-09 Thread eugenio
On Nov 8, 6:50 pm, Marnen Laibow-Koser wrote: > This would be a single DB connection, so it seems like a good candidate > for a transaction.  What's the problem with doing that? i think that multiple requests use multiple db connections, didn't they? This is obviously true having two database