ruby-on-rails

Using observe_field with multiple inputs

Hello, I'm trying to get my code to work with multiple html inputs. As of right now it works with just one input (text) but I want to introduce another two inputs as part a searching capability(displaying results with update option..) If I have three inputs, lets say search1, search2, search3 observe_field 'search1', .... :with => "'s...

Why does the server need to restart when a model file is updated?

Hi, I'd like to know why is there a need to restart the server (Mongrel/WEBrick) every time a model file is updated? I know it doesn't get loaded in if you don't do it - but is there any documentation out there that would explain why it does so? Thanks! ...

How to create individual email id to users on my domain through rails ?

I would like to create an email service for all the users on my site for ex [email protected] where users can be able to send and receive personalized emails , Basic feature only send and receive emails in Rails . User can register for email id at xyz.com and send and recieve emails from xyz.com Are there any solution already available i...

Test if a word is singular or plural in Ruby on Rails

Quick question. How can I test a word to see if it is singular or plural? I'd really like: test_singularity('word') # => true test_singularity('words') # => false I bet rails is capable! Thanks. ...

Can someone please explain to me in clear, layman's terms what the deal is with mapped resources and named routes in Ruby on Rails?

I've been using Ruby for the first time on a project at my work, so I am still somewhat learning the ropes (and loving every minute of it). While I understand the point of the map.connect functions in the route.rb file, I don't understand the "resources" and "named route" features of Rails. I have my Rails book here and read it over se...

Globalize2 Get only translated attributes from model

class Site < ActiveRecord::Base translates :title, :content attr_accessor :rank end How I can list only the attributes of the Site model, which work with the translates method ? (in this case, I should get an array with ['title', 'content'], without the rank attribute, because it is not translated. ...

render_component alternative

in routes.rb i have put: map.connect '/:alias', :controller => 'cores' ,:action=>"view" this alias is connect with 3 models: event place and artist in my cores controller i used render_component for rendering the action relative to the model. if(core = Core.find(:first, :conditions => ["alias = ?", params[:alias]])) type = c...

RSpec View testing: How to modify params?

I am trying to test my views with RSpec. The particular view that is causing me troubles changes its appearance depending on a url parameter: link_to "sort>name", model_path(:sort_by => 'name') which results in http://mydomain/model?sort_by=name My view then uses this parameter like that: <% if params[:sort_by] == 'name' %> <div>Sorte...

ActiveRecord custom validation problem

Hi, I'm having a problem with validation in my RoR Model: def save self.accessed = Time.now.to_s self.modified = accessed validate_username super end def validate_username if User.find(:first, :select => :id, :conditions => ["userid = '#{self.userid}'"]) self.errors.add(:userid, "already exists") end end As you ca...

rails - implementing a simple lock to prevent user's from editing the same data concurrently

Hi - I have an app where I need to prevent users from editing data while it is being edited by a different user. I'm trying to think of the best way to do it and wanted to ask for ideas. So far, I've created a settings model that stores application wide configuration on the db in key/value pairs. So, for the lock, I have a settings insta...

Why does mysqldump need to be fully pathed when called from a controller or model?

When I call mysqldump from a controller or model I need to fully path the binary, when I call it from Rake I don't need to. If I do not fully path I get a zero byte file... I can confirm both processes are run using the same user. # Works in a controller, model and Rake task system "/usr/local/mysql/bin/mysqldump -u root #{w.database_...

How to use paperclip with a file already on my server?

For the record, I'm working on legacy code and I'm trying to plug a new feature without breaking everything. Right now I have a bunch of files on my server as such: myapp/public/temp/myfile.doc The thing is that I want to create a Docfile object from these files in a controller action. Here is the trimmed down Docfile class: class ...

Adding extra SQL queries in a Redmine core view (overriding view in plugin)

I'am overriding a Redmine core view in my plugin (/views/reports/_details.rhtml). Just to print some extra data, like how many open issues are assigned and not assigned. I tried to override the controller instead and add a method to do this, but I never got it to work, so I added the code below to the view (yes, it's ugly, but the page ...

avoiding redirect

Depending on the subdomain I want to call a specific controller. What I currently do: My page uses the subdomain to identify users like username.site.com. I get the username, look it up in the database and render the appropriate data in the UsernamesController. the only exception to this is www.site.com or site.com . In that case anot...

Rails and I18n: localized templates vs localized string

As you probably know, starting from Rails 2.2, Rails is shipped with a simple localization and internationalization backend. By default, you can store the strings you need to translate in the localization files within the config folder. config/locales/en.yml config/locales/it.yml But Rails provides the ability to localize templates a...

RoR: Link_to_remote - updating text field

I'm trying to use rails to change a textfield's value with a link_to_remote <%= link_to_remote address.street, :url => {:controller => 'incidents', :action=>'street_selected', :update => "street.value" } %> Street is the id of the textfield my controller function renders text, but the textfield value isn't changed. How do i get this ...

learning http and cgi

I just learned ruby, and already have some html/javascript/css background. When i learn rails i found that there's just too much magic. I want to use ruby to create a dynamic website from scratch - just for learning all the underlying stuff. So is there any book or article well suited for me to getting started with? thanks in advance! so...

Rails/MySQL: Knowing a version number for a table, or the entire db schema

As an API endpoint, I need to provide a table schema with a version number so that the mobile developers I am working with can cache the schema until it changes again. I am automating this process, which complicates the "versioning" idea. At first I thought that I could use the latest migration number as the version # but it occurred ...

How thorough should you get with RSpec testing?

I'm just starting to grasp BDD and RSpec and one thing I'm really having trouble with is figuring out how thorough I should be with my testing. I'm just not understanding how fine-grained my testing should be to still be useful but not double development time. Is it just a matter of preference? Or is there some general standard for wha...

warbler config and jruby version

I just installed jruby-1.4.0 to play around with it. I'm noticing however that warbler is packaging this by default with my rails deploy. My production uses jruby-complete-1.3.1 (which I've added to my lib dir to freeze the version) but warbler is adding jruby-core-1.4 when it packages everything up. That's a bit worrisome for me as I...