[Rails] Re: hi

2010-03-05 Thread Viorel
Hi, Kevid! Have you tried scaffolding? It shold do the trick, you have only to delete unnecessary data in index.html.erb and move the link to name. -- 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

Re: [Rails] White Labeling (Easily Rebranding) Rails Applications

2010-03-05 Thread Andy Jeffries
Sure, provide a way for admins to upload a CSS file and support subdomains/hostnames to load the correct CSS files. If you need to load different data for each one, simply have a table of supported white label sites/customers and then have a field in each table (indexed) for that customer_id.

Re: [Rails] Rails 3 and Friendship models

2010-03-05 Thread Peng Zhong
When I try to add user_3 as a friend using the following code: = link_to 'Add Friend', friendships_path(:friend_id = user), :method = :post #= which generates http://localhost:3000/friendships?friend_id=3 This is what happens in my server console: Started GET /friendships?friend_id=3 for

[Rails] Re: Validations question

2010-03-05 Thread Viorel
If the field is empty, then self.start_date is nil. Try this: def start_date_should_not_be_greater_than_current_date   if !self.start_date.nil? if self.start_date Date.today     errors.add(Whatever)   end end end or something similar On Mar 5, 8:08 am, Hemant Bhargava

Re: [Rails] Single form multiple table

2010-03-05 Thread Gael Muller
On Fri, Mar 5, 2010 at 7:22 AM, M I R m.irfa...@gmail.com wrote: Hi, I want to insert data into multiple database tables from a single form, look at the detail. tables: patients, patient_history, patient_address, first i will insert data into patient table and then the patient primary key

Re: [Rails] how to share variables in data migrations (up/down)

2010-03-05 Thread Michael Pavling
On 4 March 2010 23:36, Gordon Yeong anexi...@gmail.com wrote: Assuming an online t-shirt sales application, each order catalogue would have the following statuses throughout the life of the application. It would be worth your time to look at using a state machine then. Either roll your own

Re: [Rails] Form Question

2010-03-05 Thread Andy Jeffries
%= form.input :first_name% %= form.input :last_name% %= link_to_function clear, :id = , this.up('li').remove() % This works fine but the link is located outside of the li tag which causes the formatting to be weired. How can I generate this link and position it within the li tag it is

Re: [Rails] Validations question

2010-03-05 Thread Andy Jeffries
validate :start_date_should_not_be_greater_than_current_date Personally I'd rename that to: valid :start_date_before_now And then I'd do this as the method: def start_date_before_now if start_date start_date Date.today errors.add(Whatever) end end Just check start_date first.

Re: [Rails] Re: how to share variables in data migrations (up/down)

2010-03-05 Thread Michael Pavling
On 4 March 2010 19:51, Hassan Schroeder hassan.schroe...@gmail.com wrote: So do I -- but migrating down multiple levels and back up has never entered the picture. Good for you. So you never need to migrate; so you never have migration troubles. However, those people that do migrate (and not

[Rails] Re: hi

2010-03-05 Thread kevid
Viorel, Thanks for your response. the array i have is the result of a webservice. Its a data I pulled from another web site. my rails application has no model - just a form {in index.erb} to send specific data to a webservice (defined in my controller.rb). it is this websevice that returns

[Rails] Changing the plugin load path from a plugin-init.rb

2010-03-05 Thread neomizer
Hi, I'm in the middle of converting one of my Rails-Apps to a plugin/ engine. Because this new plugin requires a lot of plugins I moved them to RAILS_ROOT/vender/plugins/my_plugin/plugins and added config.plugin_paths += %W( #{RAILS_ROOT}/vendor/plugins/my_plugin/ plugins ) to my

[Rails] Automating CSS in a plugin

2010-03-05 Thread John Lane
Hi, I'm looking for advice on how best to implement a plugin that contains some CSS. I would like the CSS to be automatically added to any layout so that the only action I need to perform is installation of the plugin. Is this possible? The reason for this is that the plugin includes some view

[Rails] Re: Rails 3 and Friendship models

2010-03-05 Thread Rakoth
There is a bug in prototype.js, therefore method handler dont work correctly in rails.js Try to install latest prototype from repository or use jquery. https://rails.lighthouseapp.com/projects/8994/tickets/4013-link_to-with-method-doesnt-work -- You received this message because you are

[Rails] Re: Validations question

2010-03-05 Thread Hemant Bhargava
Andy Jeffries wrote: validate :start_date_should_not_be_greater_than_current_date Personally I'd rename that to: valid :start_date_before_now And then I'd do this as the method: def start_date_before_now if start_date start_date Date.today errors.add(Whatever) end end

[Rails] Modelling Question

2010-03-05 Thread Anthony Gardner
Let's say I have the following real life objects Books, Authors, Roles. A Book can have one or many Authors and an Author can have one or many Books. An Author can also have one or many roles associated with a book (maybe they're the author, or co-author, or commentator to whatever) How would you

[Rails] Re: undefined method `build' for nil:NilClass

2010-03-05 Thread mac
I would very strongly suggest following the conventions, it will make your life much easier.  Also I think that in this case it may at least in part be the cause of the problem.  Consider the line @metadata = @content_master.Metadata.build What is Metadata here?  In the model you have

Re: [Rails] Re: undefined method `build' for nil:NilClass

2010-03-05 Thread Michael Pavling
On 5 March 2010 12:45, mac care4u.jodh...@gmail.com wrote: I suppose their is lots and lots of chaos about rails conventions defaults. Not really... problem still remains unsolved  ! Post the new/modified code and we can have a look. -- You received this message because you are

[Rails] Re: Modelling Question

2010-03-05 Thread Max Williams
I would do: Book has_many :authorings has_many :authors, :through = :authorings Authoring belongs_to :book belongs_to :author has_many :authoring_roles has_many :roles, :through = :authoring_roles AuthoringRole belongs_to :authoring belongs_to :role Role has_many

[Rails] Re: undefined method `build' for nil:NilClass

2010-03-05 Thread mac
Post the new/modified code and we can have a look. 1) content_master model class ContentMaster ActiveRecord::Base has_one :metadata end 2) metadata model: class Metadata ActiveRecord::Base belongs_to :content_master end 3) def new @content_master = ContentMaster.new

Re: [Rails] Re: Modelling Question

2010-03-05 Thread Andy Jeffries
Book Authoring AuthoringRole Role Author I did this in 3 models, I don't know who models the OP's requirements more closely, but for now here's my modelling: http://gist.github.com/322710 Ready for the follow-up :-) Cheers, Andy -- You received this message because you are

[Rails] Re: undefined method `build' for nil:NilClass

2010-03-05 Thread mac
hello, i found this through google The create and build methods are only available for has_one/ belongs_to if an association already exist. It will not work when it's nil. http://dev.rubyonrails.org/ticket/535 though this is really a old post i dont know that it is solved or not. thank you

Re: [Rails] Re: undefined method `build' for nil:NilClass

2010-03-05 Thread Andy Jeffries
i found this through google The create and build methods are only available for has_one/ belongs_to if an association already exist. It will not work when it's nil. http://dev.rubyonrails.org/ticket/535 though this is really a old post i dont know that it is solved or not. Well,

Re: [Rails] Re: Rails 3 and Friendship models

2010-03-05 Thread Peng Zhong
Rakoth, awesome detective work. Friend-adding seems to be working now. On Fri, Mar 5, 2010 at 2:15 AM, Rakoth rakot...@gmail.com wrote: There is a bug in prototype.js, therefore method handler dont work correctly in rails.js Try to install latest prototype from repository or use jquery.

[Rails] Re: Re: Modelling Question

2010-03-05 Thread Max Williams
Hi Andy - why not just post your code here? Saves clicking away, and it's easier to discuss the code. Anyway, you posted class Role ActiveRecord::Base belongs_to :author belongs_to :book end class Book ActiveRecord::Base has_many :authors, :through = :roles has_many :roles end

Re: [Rails] Re: undefined method `build' for nil:NilClass

2010-03-05 Thread Michael Pavling
On 5 March 2010 13:18, mac care4u.jodh...@gmail.com wrote: The create and build methods are only available for has_one/ belongs_to if an association already exist. It will not work when it's nil. http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html For a has_one, it

Re: [Rails] Re: undefined method `build' for nil:NilClass

2010-03-05 Thread Michael Pavling
On 5 March 2010 13:26, Andy Jeffries andyjeffr...@gmail.com wrote: def new   �...@content_master = ContentMaster.new  �...@content_master.metadata = Metadata.new    respond_to do |format|      format.html # new.html.erb      format.xml  { render :xml = @content_master }    end  end I like

[Rails] Re: Why all columns of joined table get instantiated as String?

2010-03-05 Thread Jack Shanter
Thanks, Fred. I suppose I'll stick with views and conversions. -- 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-t...@googlegroups.com. To

[Rails] Strange error on the first request - trying to setup Rails 2.3.5 with Bundler

2010-03-05 Thread szimek
I'm trying to use Bundler for existing Rails 2.3.5 app and got a very strange problem. The problem is that on the very first request only the contents of the action view file are rendered - i.e. when loading the home page (controller: home, action: index) I get only contents of the app/views/

[Rails] Re: Re: Modelling Question

2010-03-05 Thread Max Williams
Andy Jeffries wrote: Also by using a string for the role_type you will have many Role records with MAIN_AUTHOR for example. If you later decided that Primary Author would be better you would have to change the string in many records. I'm not saying MAIN_AUTHOR has to be displayed

[Rails] Re: Re: Re: Errors in rake db:create

2010-03-05 Thread Tasneem Yusuf
Thanks everyone , it turns out that doing the age-old trick of re-installing the app has solved this problem. Thanks, kannav rajeev wrote: Hey sorry i think first please write yours migration code so i can help you out. First Do this then else thanks .. On 3/4/10, kannav rajeev

Re: [Rails] Re: Re: Modelling Question

2010-03-05 Thread Andy Jeffries
Rails finds it easier to use foreign keys based on id. Are we talking about rails or about a person manually searching the database using their hands and eyes? A person manually scanning the database (in a MySQL command prompt). If this was actually a useful table (as opposed to just

[Rails] Re: undefined method `build' for nil:NilClass

2010-03-05 Thread mac
thank you @Andy thank you @Michael both method work in action new but comming back to problem as i was following http://media.railscasts.com/videos/073_complex_forms_part_1.mov i need to create a virtual function in a model i tried various combination (for * ) but failed model: class

[Rails] Re: undefined method `build' for nil:NilClass

2010-03-05 Thread mac
thank you @Andy thank you @Michael both method work in action new but comming back to problem as i was following http://media.railscasts.com/videos/073_complex_forms_part_1.mov i need to create a virtual function in a model i tried various combination (for * ) but failed model: class

[Rails] Output String while expecting hash

2010-03-05 Thread Prashanth
Hi I have been trying to fetch the output as an hash but it is returning string.I am storing the data in the following format. --- :input_type: - text_field - ride_from :label: Ride From :input_type: - text_field - ride_from :label: Ride From -

[Rails] WEBrick 500 error only with https

2010-03-05 Thread bob
I have an application i'm installing on my application server. I've been using WEBrick and for now i'd like to just keep using it working in prototype development mode. This works fine on my development machine using both http and https, where the host is 'localhost' (ports 3000,3001). It also

[Rails] How to change a text field's contents to all uppercase letter

2010-03-05 Thread xxdesmus
Hi, I'm relatively new to RoR so pardon if this is a really stupid question. I have a text field where people will be entering a username. I need to figure out a way to either 1. validate the field so that it will not be accepted unless they've entered all uppercase letters for their username --

[Rails] Re: How to change a text field's contents to all uppercase letter

2010-03-05 Thread xxdesmus
I'd be putting this: def username=(value) write_attribute(:username, value.upcase) end in my controller right? Sorry for the beginning questions... On Mar 5, 11:12 am, Michael Pavling pavl...@gmail.com wrote: On 5 March 2010 16:05, Andy Jeffries andyjeffr...@gmail.com wrote: 2.

[Rails] Re: How to change a text field's contents to all uppercase letter

2010-03-05 Thread xxdesmus
When I add this to my model: def after_initialize :date = Date.today end I get this error -- /home/xxdesmus/timetool/app/models/post.rb:38: syntax error, unexpected '=', expecting kEND :date = Date.today ^ when I try it this way: def after_initialize date = Date.today end It

Re: [Rails] RegEx help to detect First and Last name

2010-03-05 Thread Hassan Schroeder
On Thu, Mar 4, 2010 at 10:53 PM, Allan Last li...@ruby-forum.com wrote: I run into problems where the name is close to the beginning of the sentence: Having John Smith over for dinner. --- This will look at Having John Getting Jane Smith ready for school. --- This will look at Getting Jane

[Rails] Re: has anybody made actionmailer work with rails 2.3.5?

2010-03-05 Thread Bigos
I have managed to make it work. After changing config/environments/ development.rb to look like: config.action_mailer.raise_delivery_errors = true config.action_mailer.perform_deliveries = true config.action_mailer.delivery_method = :sendmail Now everything works fine on my system. Adding

Re: [Rails] Re: Why all columns of joined table get instantiated as String?

2010-03-05 Thread Rick DeNatale
On Fri, Mar 5, 2010 at 9:07 AM, Jack Shanter li...@ruby-forum.com wrote: Thanks, Fred. I suppose I'll stick with views and conversions. Why not pages = Page.all(:include = :book) pages.first.book.year -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter:

Re: [Rails] Re: undefined method `build' for nil:NilClass

2010-03-05 Thread Rick DeNatale
On Fri, Mar 5, 2010 at 8:12 AM, mac care4u.jodh...@gmail.com wrote: 3)  def new   �...@content_master = ContentMaster.new   �...@metadata = @content_master.metadata.build @metadata = @content_master.build_metadata -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter:

Re: [Rails] RegEx help to detect First and Last name

2010-03-05 Thread Rick DeNatale
On Fri, Mar 5, 2010 at 12:16 PM, Hassan Schroeder hassan.schroe...@gmail.com wrote: On Thu, Mar 4, 2010 at 10:53 PM, Allan Last li...@ruby-forum.com wrote: I run into problems where the name is close to the beginning of the sentence: Having John Smith over for dinner. --- This will look at

[Rails] Re: undefined method `build' for nil:NilClass

2010-03-05 Thread mac
thank you for your reply @RickDeNatale but solution u provided has allready been suggested. my problem is now with defination of virtual function according to has_one relation thank you anyway mac -- You received this message because you are subscribed to the Google Groups Ruby on Rails:

[Rails] How to create Rails models w/ multiple complex associations?

2010-03-05 Thread Chris Benson
I am trying to figure out how to create ActiveRecord models with associations that can yield the same results as this SQL query: select login, first_name, last_name, email_address from accounts inner join people on person.id = accounts.person_id inner join email_address_people on person.id =

[Rails] Making async tcp connections from rails

2010-03-05 Thread snacktime
So I've never really found a solution I like for making async tcp connections from inside a running rails app, and was curious if anyone else has had any luck. When running fairly large scale rails apps we always end up needing this. The only thing I've tried so far that really works is to run

[Rails] Re: has anybody made actionmailer work with rails 2.3.5?

2010-03-05 Thread Phillip Koebbe
On Mar 5, 12:14 pm, Bigos ruby.obj...@googlemail.com wrote: I have managed to make it work. After changing config/environments/ development.rb to look like: config.action_mailer.raise_delivery_errors = true config.action_mailer.perform_deliveries = true

[Rails] Re: Re: Why all columns of joined table get instantiated as String?

2010-03-05 Thread Jack Shanter
Rick Denatale wrote: Why not pages = Page.all(:include = :book) I usually need to filter by, let's say, a certain library: @pages = Page.all( :select = 'pages.id, pages.no', :joins = :book, :conditions = books.library_id = #{1} ) AR will generate: SELECT pages.id, pages.no FROM pages

[Rails] Re: WEBrick 500 error only with https

2010-03-05 Thread bob
Never mnddd. Figured it out finally. In the startup script, the definition of OPTIONS :environment needs to be changed from 'development' to 'production'. (My use of -e isn't actually implemented by this script.) On Mar 5, 8:09 am, bob bwor...@keycomputerconsultants.com wrote: I have an

Re: [Rails] Re: How to change a text field's contents to all uppercase letter

2010-03-05 Thread Michael Pavling
On 5 March 2010 17:02, xxdesmus xxdes...@gmail.com wrote: So I have a bunch of form fields that I need to add up their values, and make sure their sum does not except the value entered in a new form field. If the sum does exceed the form field value then I want to alert the user and prevent it

[Rails] Re: [slightly OT] Grokking agile practices

2010-03-05 Thread Ar Chron
Phoenix Rising wrote: Here's where agile practices come into play, and where the rub is: I had an entire system finished and ready to go. Then management stepped in, and for the third time in two months, changed it all. Four user types got expanded to 9, and instead of 4-8 sub parts for

[Rails] Three submits, one controller

2010-03-05 Thread Neil Bye
I have a 'new' page with a submit for creating stories. On the 'show' page the submit allows a user to enter comments. I now want a 'edit' page for the stories with another submit for updates. I have used the 'create' and 'update' methods in the stories_controller on the 'new' and 'show' pages.

Re: [Rails] Three submits, one controller

2010-03-05 Thread Colin Law
On 5 March 2010 20:33, Neil Bye li...@ruby-forum.com wrote: I have a 'new' page with a submit for creating stories. On the 'show' page the submit allows a user to enter comments. I now want a 'edit' page for the stories with another submit for updates. I have used the 'create' and 'update'

[Rails] Re: Re: how to share variables in data migrations (up/down)

2010-03-05 Thread Marnen Laibow-Koser
Hassan Schroeder wrote: On Thu, Mar 4, 2010 at 5:18 AM, Marnen Laibow-Koser li...@ruby-forum.com wrote: However, your original example is problematic. You appear to be using migrations for seed data. This is a terrible idea. Why? For several reasons. The two most compelling for me are

[Rails] Re: Three submits, one controller

2010-03-05 Thread Paul E. G. Lynch
You can also just add another public method to the controller. For instance, instead of using StoryController.update for updating the comments, you could use something like StoryController.add_comment. On Mar 5, 4:07 pm, Colin Law clan...@googlemail.com wrote: On 5 March 2010 20:33, Neil Bye

[Rails] Re: how to install rails without gems?!

2010-03-05 Thread janita kinsi
gems is a kind of packet manager for ruby's 3rd party application. we can download rails with that. but i can download it with that. is there any other solution? On Mar 2, 5:59 pm, kannav rajeev rajeevsharm...@gmail.com wrote: What is Gem ?.. On Tue, Mar 2, 2010 at 2:22 PM, janita kinsi

Re: [Rails] how to install rails without gems?!

2010-03-05 Thread Conrad Taylor
On Tue, Mar 2, 2010 at 12:52 AM, janita kinsi jki...@gmail.com wrote: i have install ruby on my computer. but what if i want to install rails manually without install gem first?! Hi, you'll need to download the sources from github.com. For example, you'll need to do the following: $ git

[Rails] text_field value as a local variable in in-line template function

2010-03-05 Thread Grary
Hi, I'd like to conserve the sum total of several text fields on my form, even as I set them to blank upon a user link action. The following in-line snippet fails to store the value of my sum total field locally for eventual reassignment. (I am re-assigning it because the fields all have an

[Rails] Re: jQuery conversion - how to replace :onchange = remote_function() call?

2010-03-05 Thread lunaclaire
OK, I figured it out. Though I wonder why it was so hard to do so... :-) Here's what I'm doing in case others have the same questions and find this... now in my view template I have: %= select_tag :selected_email, options_from_collection_for_select(update_request.contact.emails, 'id',

[Rails] Re: jQuery conversion - how to replace :onchange = remote_function() call?

2010-03-05 Thread lunaclaire
OK, I figured it out. Though I wonder why it was so hard to do so... :-) Here's what I'm doing in case others have the same questions and find this... now in my view template I have: %= select_tag :selected_email, options_from_collection_for_select(update_request.contact.emails, 'id',

Re: [Rails] Re: Re: Why all columns of joined table get instantiated as String?

2010-03-05 Thread Rick DeNatale
On Fri, Mar 5, 2010 at 2:12 PM, Jack Shanter li...@ruby-forum.com wrote: Rick Denatale wrote: Why not pages = Page.all(:include = :book) I usually need to filter by, let's say, a certain library: @pages = Page.all(  :select = 'pages.id, pages.no',  :joins = :book,  :conditions =

[Rails] Re: jQuery conversion - how to replace :onchange = remote_function() call?

2010-03-05 Thread lunaclaire
OK, I figured it out. Though I wonder why it was so hard to do so... :-) Here's what I'm doing in case others have the same questions and find this... now in my view template I have: %= select_tag :selected_email, options_from_collection_for_select(update_request.contact.emails, 'id',

[Rails] searchlogic is_any needs to be switched to equals_any

2010-03-05 Thread Ease Bus
Does is_any has a bug in searchlogic? is_any used to work fine for me. All of a sudden now, for unknown reasons, when I write for example :attribute_is_any = [1] , the sql output is where attribute != 1 which is the opposite of what I want of course. Curiously, the problem only occurs when

[Rails] Restful-authentication plugin for rails3

2010-03-05 Thread John Wu
Hi, I just installed Restful-authentication plugin and tried rails g authenticated user sessions and got Could not find generator authenticated. What is the problem? Thanks -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups

Re: [Rails] searchlogic is_any needs to be switched to equals_any

2010-03-05 Thread Conrad Taylor
On Fri, Mar 5, 2010 at 6:03 PM, Ease Bus ease...@gmail.com wrote: Does is_any has a bug in searchlogic? is_any used to work fine for me. All of a sudden now, for unknown reasons, when I write for example :attribute_is_any = [1] , the sql output is where attribute != 1 which is the

[Rails] Re: RegEx help to detect First and Last name

2010-03-05 Thread Allan Last
Thanks for the suggestions. I'm going to play around with this. On the most part, I'm doing detection for scenarios with two names, so names like Robert De Niro will not come up. -A Rick Denatale wrote: On Fri, Mar 5, 2010 at 12:16 PM, Hassan Schroeder hassan.schroe...@gmail.com wrote: You

[Rails] Two Version of Rails on one machine

2010-03-05 Thread John Wu
Hi, I installed rails3 on my mac and after installing 2.3.5 using gem install rails -v 2.3.5, if I run gem list rails, I got *** LOCAL GEMS *** rails (3.0.0.beta, 2.3.5) But if I run rails _3.0.0.beta_ test got the following error can't find executable rails for rails-3.0.0.beta

[Rails] How to make routes that mimi Flickr's URLs

2010-03-05 Thread Steve Wilhelm
I have two resources, :users and :photos. Users is based on AuthLogic. Photos has a type set to private or public. I would like configure my routes to mimic the Flickr URL structure. The routes I want are: foo.com/photos = controller = photos, action = index, This route will display the

[Rails] How to do personal domains like del.icio.us

2010-03-05 Thread Cristian Vasquez
Hi, I am looking for a solution in my application, i want to provide a personal domain to my users just like del.icio.us do, i don't want a subdomain, i just want that people can choose to show some information and give other people a link like www.myapplication.com/name_of_user. i want to

Re: [Rails] How to do personal domains like del.icio.us

2010-03-05 Thread Ivan Nastyukhin
1. Use subdomains and cname records. 2if name unic, in your model write def to_param name end Sent from my iPhone On 06.03.2010, at 10:08, Cristian Vasquez li...@ruby-forum.com wrote: Hi, I am looking for a solution in my application, i want to provide a personal domain to my users just