[Rails] Re: can split form_for into two parts?

2012-11-15 Thread Soichi Ishida
Is there anyway to manipulate form_tag from controllers? Like, in order to edit, _form.html.erb must to be filled with the values for the model. At the same time, there are some checkbox or radio buttons related to the form, but they are not needed for the model directly. I want to choose the v

[Rails] Re: can split form_for into two parts?

2012-11-15 Thread Soichi Ishida
> Show Options > > f.field A > > f.field B, :class => 'optional' > > > var hidden_fields = $$('.optional').invoke('hide'); > $('show_options').observe('click', > function(evt){ > hidden_fields.invoke('toggle'); > } > ); > > > Walter Oh, thanks. Simpler than I thought. soichi -- Poste

[Rails] Re: How to stop ruby escaping javascript?

2012-11-15 Thread Sam Pei
Robert Walker wrote in post #1084592: > Sam Pei wrote in post #1084545: >> Max Shytikov wrote in post #1084457: >> I can't figure out how to pass a ruby variable into an external css or >> js file... >> >> So I have to keep all the code in one big (sigh!) rhtml... > > The simplest way is to not pas

Re: [Rails] How can I prevent ENTER from submitting form?

2012-11-15 Thread Walter Lee Davis
On Nov 15, 2012, at 12:26 PM, Albert Català wrote: > Jordon Bedwell wrote in post #1084597: >> On Thu, Nov 15, 2012 at 10:23 AM, Albert Catal >> wrote: >>> Easy and clean, thanks you >> >> If you want/need to prevent "enter" from submitting a form, you are >> doing it wrong and you could be be

Re: [Rails] in standby for an annoying problem.

2012-11-15 Thread Colin Law
On 15 November 2012 17:56, Jordon Bedwell wrote: > On Thu, Nov 15, 2012 at 11:15 AM, Colin Law wrote: >> I was trying to ask the general question, that if one has a scope and >> a class method that perform exactly the same operation (such as the >> example in this thread), so >> >> scope :today_r

Re: [Rails] in standby for an annoying problem.

2012-11-15 Thread Jordon Bedwell
On Thu, Nov 15, 2012 at 11:15 AM, Colin Law wrote: > I was trying to ask the general question, that if one has a scope and > a class method that perform exactly the same operation (such as the > example in this thread), so > > scope :today_reservations, lambda { where("reserved_from > ? and > re

[Rails] Re: Re: How can I prevent ENTER from submitting form?

2012-11-15 Thread Albert Català
Jordon Bedwell wrote in post #1084597: > On Thu, Nov 15, 2012 at 10:23 AM, Albert Catal > wrote: >> Easy and clean, thanks you > > If you want/need to prevent "enter" from submitting a form, you are > doing it wrong and you could be be alienating some disabled people who > do not use a mouse and r

Re: [Rails] in standby for an annoying problem.

2012-11-15 Thread Colin Law
On 15 November 2012 17:06, Jordon Bedwell wrote: > On Thu, Nov 15, 2012 at 10:37 AM, Colin Law wrote: >> Experimentation shows me that you are right, that is a bit of rails >> magic that I was not aware of. In fact it seems that one can call any >> class method on an ActiveRecord relation for th

Re: [Rails] in standby for an annoying problem.

2012-11-15 Thread Jordon Bedwell
On Thu, Nov 15, 2012 at 10:37 AM, Colin Law wrote: > Experimentation shows me that you are right, that is a bit of rails > magic that I was not aware of. In fact it seems that one can call any > class method on an ActiveRecord relation for the class. Thanks for > the education. It's one of my f

Re: [Rails] Re: How can I prevent ENTER from submitting form?

2012-11-15 Thread Jordon Bedwell
On Thu, Nov 15, 2012 at 10:23 AM, Albert Català wrote: > Easy and clean, thanks you If you want/need to prevent "enter" from submitting a form, you are doing it wrong and you could be be alienating some disabled people who do not use a mouse and rely on their keyboard. I know even if that's not

Re: [Rails] in standby for an annoying problem.

2012-11-15 Thread Colin Law
On 15 November 2012 16:06, Jim Ruther Nill wrote: > > > > On Thu, Nov 15, 2012 at 10:19 PM, Colin Law wrote: >> >> On 15 November 2012 09:11, Jim Ruther Nill wrote: >> > ... >> > Colin is right but you can also use class methods so you dont have to >> > worry >> > about >> > adding lambdas >> >

[Rails] Re: How to stop ruby escaping javascript?

2012-11-15 Thread Robert Walker
Sam Pei wrote in post #1084545: > Max Shytikov wrote in post #1084457: > I can't figure out how to pass a ruby variable into an external css or > js file... > > So I have to keep all the code in one big (sigh!) rhtml... The simplest way is to not pass the data to JavaScript, but rather get the va

[Rails] Re: How can I prevent ENTER from submitting form?

2012-11-15 Thread Albert Català
Easy and clean, thanks you -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to

Re: [Rails] Create a Migration from an existing table?

2012-11-15 Thread RVince
I have to commit my code changes on this specific project and it has to comport to having a migration for a new db table that was required here. I could cobble one by hand, but I think that's even more kludgey! I assume it isn't possible to go from a table to a migration? Thanks. On Thursday, N

Re: [Rails] Create a Migration from an existing table?

2012-11-15 Thread Walter Lee Davis
On Nov 15, 2012, at 11:01 AM, RVince wrote: > If I have a table in MySQL on an existing Rails project, how do I go to > creating a migration for it? All the examples I see online seem to be geared > to creating models and tables from a migration -- but how do I go the other > way and create a

Re: [Rails] Create a Migration from an existing table?

2012-11-15 Thread Colin Law
On 15 November 2012 16:01, RVince wrote: > If I have a table in MySQL on an existing Rails project, how do I go to > creating a migration for it? All the examples I see online seem to be geared > to creating models and tables from a migration -- but how do I go the other > way and create a migrati

Re: [Rails] in standby for an annoying problem.

2012-11-15 Thread Jim Ruther Nill
On Thu, Nov 15, 2012 at 10:19 PM, Colin Law wrote: > On 15 November 2012 09:11, Jim Ruther Nill wrote: > > > > > > > > On Thu, Nov 15, 2012 at 4:51 PM, Colin Law > wrote: > >> > >> On 15 November 2012 08:09, Mauro wrote: > >> > On 14 November 2012 22:21, Colin Law wrote: > >> >> On 14 Novembe

[Rails] Create a Migration from an existing table?

2012-11-15 Thread RVince
If I have a table in MySQL on an existing Rails project, how do I go to creating a migration for it? All the examples I see online seem to be geared to creating models and tables from a migration -- but how do I go the other way and create a migration itself from a table? Thank you. -- You rec

Re: [Rails] in standby for an annoying problem.

2012-11-15 Thread Colin Law
On 15 November 2012 09:11, Jim Ruther Nill wrote: > > > > On Thu, Nov 15, 2012 at 4:51 PM, Colin Law wrote: >> >> On 15 November 2012 08:09, Mauro wrote: >> > On 14 November 2012 22:21, Colin Law wrote: >> >> On 14 November 2012 21:07, Mauro wrote: >> >>> I have a model Reservation with reserv

Re: [Rails] can split form_for into two parts?

2012-11-15 Thread Walter Lee Davis
On Nov 15, 2012, at 1:15 AM, Soichi Ishida wrote: > Rails 3.1.3 > > Is it possible to split form_for block into two parts? > > More specifically, I want to create and save a model after filling > required fields. > But some of the fields are not required and unnecessary for the model. > > <%=

[Rails] Re: How to stop ruby escaping javascript?

2012-11-15 Thread Sam Pei
Max Shytikov wrote in post #1084457: > Only one solution you should use method 'tag' directly > https://github.com/rails/rails/blob/39b9c943b7ec5181c19461d319d8c610ea1bf941/actionpack/lib/action_view/helpers/tag_helper.rb#L65 Thank you, This works! But finally I ended making a getElementById("

Re: [Rails] Cancan question - create rule issue

2012-11-15 Thread Ace Suares
I Think a validation will only work after data is entered. With authorization (as in CanCan) the possibility of creating a new proposal can be avoided all together. I did some experiments but yes, it's possible to put extra arguments into the initialize method. For instance, initialize(user, p

[Rails] Showing error messages in active admin for has many relationship

2012-11-15 Thread Piyush
I am facing an issue showing up the error messages in active admin. I get all the error messages displayed with the fields in the form. But in the code below, I need atleast one skill and maximum 5 skills to be added. Else need to throw an error message. I've added a validation in model as :

[Rails] Re: using Thin web server configuration in development , how to have eq. Apache RedirectMatch permanent

2012-11-15 Thread Erwin
[SOLVED] but using Rails3 routes, maybe there is a better way ? host = Rails.application.config.action_mailer.default_url_options[:host] constraints(:host => host ) do root :to => redirect("http://www.#{host}";) match '/*path', :to => redirect {|params| "http://www.#{host}/#{params[:

[Rails] using Thin web server configuration in development , how to have eq. Apache RedirectMatch permanent

2012-11-15 Thread Erwin
In production, using Apache I can use RedirectMatch permanent to force url wo subdomain to use www. ServerName example.com RedirectMatch permanent ^/(.*) http://www.example.com/$1 How can I get the same behavior when using Thin in dev mode ? need to change all example.com/.. url

Re: [Rails] in standby for an annoying problem.

2012-11-15 Thread Jim Ruther Nill
On Thu, Nov 15, 2012 at 4:51 PM, Colin Law wrote: > On 15 November 2012 08:09, Mauro wrote: > > On 14 November 2012 22:21, Colin Law wrote: > >> On 14 November 2012 21:07, Mauro wrote: > >>> I have a model Reservation with reserved_from and reserve_to > >>> attributes of type date. > >>> I wan

Re: [Rails] in standby for an annoying problem.

2012-11-15 Thread Colin Law
On 15 November 2012 08:09, Mauro wrote: > On 14 November 2012 22:21, Colin Law wrote: >> On 14 November 2012 21:07, Mauro wrote: >>> I have a model Reservation with reserved_from and reserve_to >>> attributes of type date. >>> I want create a scope of all reservations where Date.today is between

[Rails] Writin Test case

2012-11-15 Thread avinash behera
Hello, I am new to writing test cases in ruby on rails. This is a controller code I am using "test_helper" in our application. def edit @user = User.find_by_token(params[:id]) if @user if @user.sent_at < 24.hours.ago redirect_to root_url, :alert => "Expired" elsif @u

Re: [Rails] in standby for an annoying problem.

2012-11-15 Thread Mauro
On 14 November 2012 22:21, Colin Law wrote: > On 14 November 2012 21:07, Mauro wrote: >> I have a model Reservation with reserved_from and reserve_to >> attributes of type date. >> I want create a scope of all reservations where Date.today is between >> reserved_from and reserved_to. >> In the mo