[Rails] Re: how to get rid of nil values in session?

2011-02-04 Thread arunmehta


On Feb 5, 1:09 am, "Robert Pankowecki (rupert)"
 wrote:
> How about deleting them in some after filter ?
>
> session.keys.each do |k|
>   session.delete(k) if session[k].nil?
> end

Thanks, Robert, but...
session is not a regular hash, and does not seem to have the delete
function as above. Another suggestion, please?

Warmly,
Arun

-- 
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] How to give link to image in .erb file

2011-02-04 Thread amritpal pathak
i am new to ruby.I want to add one image to my webpage.Please tell me how to
give a link to image from .erb file??
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] ActionMailer

2011-02-04 Thread Bhasker Harihara
Hi,

I am planning to write an internal messaging system for my users.  Should I
be using Actionmailer ?  I am not interested in using any plugin or 3rd
party sw as I want to learn some ror.

Is actionmailer used mainly for feedback and sending general emails.

I am a new to rails so any suggestions and ideas are welcome.

Warm 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.



Re: [Rails] bundle show

2011-02-04 Thread Bhasker Harihara
Thanks Fred,

I had created the project using rails new app -d mysql which bydefault added
mysql2.

I had changed the Gemfile to use mysql instead of mysql2 but did not change
the database.yml file in the config directory.



On Fri, Feb 4, 2011 at 1:24 PM, hari  wrote:

> $ bundle show mysql
> /home/bhas/.rvm/gems/ruby-1.9.2-p136/gems/mysql-2.8.1
>
> but when I run
>
> $ rake db:migrate
> (in /home/bhas/projects/schapp)
> rake aborted!
> no such file to load -- mysql-2.8.1
> /home/bhas/projects/schapp/Rakefile:4:in `'
> (See full trace by running task with --trace)
>
>
> Please help.
>
> --
> 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.
>
>

-- 
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.



Re: [Rails] Re: How to work with Database in routes? Rails 3

2011-02-04 Thread David Kahn
On Fri, Feb 4, 2011 at 6:25 PM, Frederick Cheung  wrote:

>
>
> On Feb 4, 9:23 am, redhotberry  wrote:
> > Hello. How to check presence of object in DB in routes? If object
> > exists in DB - rais app shows its page, if not - it redirects to 404.
> > I know that it's possible to do all this logic in controller but i
> > would to know how to do it in routes.
>
> I don't think you can. Routes map urls to controllers & actions -
> that's it.
>
> Right -- seems that even if you could do this, it would be fighting the
Rails conventions. Not sure what you are really trying to achieve, but if
your concern is to intercept something before getting into a controller
action you could do a before_filter in your ApplicationController and place
this kind of logic there.


> Fred
>
> --
> 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.
>
>

-- 
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 work with Database in routes? Rails 3

2011-02-04 Thread Frederick Cheung


On Feb 4, 9:23 am, redhotberry  wrote:
> Hello. How to check presence of object in DB in routes? If object
> exists in DB - rais app shows its page, if not - it redirects to 404.
> I know that it's possible to do all this logic in controller but i
> would to know how to do it in routes.

I don't think you can. Routes map urls to controllers & actions -
that's it.

Fred

-- 
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.



Re: [Rails] rails hoster recommendation

2011-02-04 Thread JGW Maxwell
Very very hard to look past Heroku in my opinion.

-- 
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.



Re: [Rails] rails hoster recommendation

2011-02-04 Thread Frederick Cheung

On 4 Feb 2011, at 21:10, frankblizzard  wrote:

> now our actual hoster doesnt offer rails so we need another one only
> for the rails projects.
> i wonder if anyone can recommend a good rails hoster?
> its mostly smaller apps but with a lot of images / videos so a lot of
> diskspace at a reasonable price would be awesome ;)
> i am in germany, so probably a european hoster would be preferred.
> thanks for your help
> 
http://www.railshoster.de/ are a good bunch, and there's always ec2 to consider 
these days

Fred
> --f
> 
> -- 
> 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.
> 

-- 
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.



Re: [Rails] rails hoster recommendation

2011-02-04 Thread Bill Walton
You might want to take a look at using Amazon Web Services' EC2 and/or S3.

Best regards,
Bill

On Fri, Feb 4, 2011 at 3:10 PM, frankblizzard  wrote:
> hi,
>
> i work in a small web development company and we just finished some
> first applications using rails, before it was php all the way.
> now our actual hoster doesnt offer rails so we need another one only
> for the rails projects.
> i wonder if anyone can recommend a good rails hoster?
> its mostly smaller apps but with a lot of images / videos so a lot of
> diskspace at a reasonable price would be awesome ;)
> i am in germany, so probably a european hoster would be preferred.
> thanks for your help
>
> --f
>
> --
> 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.
>
>

-- 
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: Install Issue with sqlite3.dll

2011-02-04 Thread Parth B
Thank you greatly for your help Bosko. After another try and some help from 
a friend of mine your suggestions seem to have fixed the issue. Much 
appreciated!

-- 
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] rails hoster recommendation

2011-02-04 Thread frankblizzard
hi,

i work in a small web development company and we just finished some
first applications using rails, before it was php all the way.
now our actual hoster doesnt offer rails so we need another one only
for the rails projects.
i wonder if anyone can recommend a good rails hoster?
its mostly smaller apps but with a lot of images / videos so a lot of
diskspace at a reasonable price would be awesome ;)
i am in germany, so probably a european hoster would be preferred.
thanks for your help

--f

-- 
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 get rid of nil values in session?

2011-02-04 Thread Robert Pankowecki (rupert)
How about deleting them in some after filter ?

session.keys.each do |k|
  session.delete(k) if session[k].nil?
end

However you must be aware that sometimes in you application there
might be a difference between nil value and unset key (usually it is a
very rare case).

Robert Pankowecki
http://robert.pankowecki.pl

-- 
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 parse - month and day reversed

2011-02-04 Thread Robert Pankowecki (rupert)
Might wanna look at :
https://github.com/adzap/timeliness
https://github.com/adzap/validates_timeliness

Robert Pankowecki
http://robert.pankowecki.pl

-- 
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: Problem with reset session cookies causing session sharing in an unstable network.

2011-02-04 Thread Matt Jones


On Feb 3, 10:01 am, Jemmaniam  wrote:
> I was wondering if anyone might help me with a peculiar problem.  We
> are having a problem with our network that is resulting in, say, UserA
> getting UserB's response, resulting in his session cookie being reset
> and two users sharing the same session, UserB's.  Not good I know.
> Question:  Why does Rails pass the session cookie in every response
> and is it possible to turn that off?  

That's pretty much how cookies work, so I doubt there's going to be a
way to switch it off. I'd recommend you figure out what's gone wrong
to cause users to get replies to requests they didn't make, as it
seems to indicate some pretty severe problems at the TCP level...

--Matt Jones

-- 
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.



Re: [Rails] bundle show

2011-02-04 Thread Frederick Cheung


On 4 Feb 2011, at 07:54, hari  wrote:

> $ bundle show mysql
> /home/bhas/.rvm/gems/ruby-1.9.2-p136/gems/mysql-2.8.1
> 
> but when I run
> 
> $ rake db:migrate
> (in /home/bhas/projects/schapp)
> rake aborted!
> no such file to load -- mysql-2.8.1
> /home/bhas/projects/schapp/Rakefile:4:in `'
> (See full trace by running task with --trace)
> 

Could it be that although the mysql gem is present, it can't be loaded because 
(for example) it can't find a required library?
In those situations, you sometimes get a better error message by trying to load 
the gem from an irb session

Fred
> 
> Please help.
> 
> -- 
> 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.
> 

-- 
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.



Re: [Rails] Re: Date parse - month and day reversed

2011-02-04 Thread Frederick Cheung


On 4 Feb 2011, at 17:36, David Kahn  wrote:

> Ok, feel a little stupid, if I put the date in the form -mm-dd and then 
> parse it I get the right result. Anyhow, this works as a resolution for me 
> but is still I think an important question if in the case I was receiving 
> dates in something like 'mm/dd/' how I can get it to parse right.
> 
You should probably use something like strptime rather than rely on ruby 
guessing the format (which could be product of locale settings, heuristics like 
'if the first number is 15 then it can't be the month' and who knows what else

Fred 
> 
> On Fri, Feb 4, 2011 at 11:32 AM, David Kahn  
> wrote:
> I am getting the month and day reversed in parsing a date. I am wondering if 
> there is some intelligence in Ruby that knows that at the moment I am in 
> Mexico, as the parsing is working as if I was 
> 
> "6/15/2008".to_date
> => ArgumentError: invalid date
> 
> "15/6/2008".to_date
>  => Sun, 15 Jun 2008 
> 
> What I really want is my date to be understood as month/day/year. Is there a 
> way to tell Ruby or Rails to do this? Been poking around on google and do not 
> see an answer that works here. 
> 
> I found a page with this example, which makes me think maybe there is 
> something weird going on due to my geographic location:
> 
> '06/15/2008'.to_date # => Sun, 15 Jun 2008
> 
> 
> 
> 
> 
> 
> -- 
> 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.

-- 
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 parse - month and day reversed

2011-02-04 Thread David Kahn
Ok, feel a little stupid, if I put the date in the form -mm-dd and then
parse it I get the right result. Anyhow, this works as a resolution for me
but is still I think an important question if in the case I was receiving
dates in something like 'mm/dd/' how I can get it to parse right.


On Fri, Feb 4, 2011 at 11:32 AM, David Kahn wrote:

> I am getting the month and day reversed in parsing a date. I am wondering
> if there is some intelligence in Ruby that knows that at the moment I am in
> Mexico, as the parsing is working as if I was
>
> "6/15/2008".to_date
> => ArgumentError: invalid date
>
> "15/6/2008".to_date
>  => Sun, 15 Jun 2008
>
> What I really want is my date to be understood as month/day/year. Is there
> a way to tell Ruby or Rails to do this? Been poking around on google and do
> not see an answer that works here.
>
> I found a page with this example, which makes me think maybe there is
> something weird going on due to my geographic location:
>
> '06/15/2008'.to_date 
> 
>  # => Sun, 15 Jun 2008
>
>
>
>

-- 
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] Date parse - month and day reversed

2011-02-04 Thread David Kahn
I am getting the month and day reversed in parsing a date. I am wondering if
there is some intelligence in Ruby that knows that at the moment I am in
Mexico, as the parsing is working as if I was

"6/15/2008".to_date
=> ArgumentError: invalid date

"15/6/2008".to_date
 => Sun, 15 Jun 2008

What I really want is my date to be understood as month/day/year. Is there a
way to tell Ruby or Rails to do this? Been poking around on google and do
not see an answer that works here.

I found a page with this example, which makes me think maybe there is
something weird going on due to my geographic location:

'06/15/2008'.to_date

# => Sun, 15 Jun 2008

-- 
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.



Re: [Rails] Re: Where to set utf-8 encoding

2011-02-04 Thread David Kahn
On Fri, Feb 4, 2011 at 8:39 AM, Paul Bergstrom  wrote:

> Phillip wrote in post #979611:
> >
> http://blog.grayproductions.net/articles/ruby_19s_three_default_encodings
>
> Yeah, I saw that too, unusually clear on a subject that generally makes my
eyes glaze over


> Great article. Informative and educational. Thank 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
> rubyonrails-talk+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
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] [JOBS] Hiring Rails Developers - Social Networking Startup in New Hope, Pennsylvania

2011-02-04 Thread OurKudos
Dynamic Social Networking Startup Seeks Developers

Join us in building a Social Networking revolution!

We are seeking several talented, motivated, hard working web
application developers to augment our growing team. Main consideration
will be given to applicants with prior Ruby-on-Rails experience,
however applicants with other skills such as general object-oriented
programming, database design and adminstration, systems
administration, and general web application development experience
will be considered. We are considering anyone from recent college
grads to experienced web professionals. Applicants will need to attend
weekly meetings in the New Hope, PA area, the balance of work can be
conducted via telecommuting.

This is a fully funded start up and all positions are paid. Salary is
commensurate with previous experience and skills.

Send resumés or CV, cover letters via email to devj...@ourkudos.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.



Re: [Rails] Re: TinyMCE editor

2011-02-04 Thread kirti parihar
Thanks dear for reply actually i knew this jquery doesnot included
bydefault.
There was jQuery conflict...so to reslove i run jQuery in no-conflict
modenow its working fine...

On Fri, Feb 4, 2011 at 8:25 PM, frankblizzard wrote:

> might be a stupid question but did you include jquery explicitly in
> your application.html.erb file
> or whatever layout you are using? or just the :defaults?
> because jquery doesn't get included by default
>
> On 4 Feb., 07:59, kirti parihar  wrote:
> > hi...
> > I m newbie in RoR and  working on rails 3.
> > Actually i m using tiny_mce plugin in my application and following the
> steps
> > mentioned in this linkhttps://github.com/kete/tiny_mce,
> > No doubt this is working absolutely fine in application but the other
> Jquery
> > applied to the application is not working (example dynamically add and
> > remove textboxes is not working)
> > Dont know why it is so...
> > If anyone knows then help me...
> >
> > Thanks
> > kirti
>
> --
> 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.
>
>

-- 
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.



Re: [Rails] one form for one model with nested resources.

2011-02-04 Thread Mauro
On 4 February 2011 16:07, Bente Pieck  wrote:
> http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html
>
> Haven't tested it, but perhaps you try something like this:
>
> class Customer
>   has_many :deliveries
>   has_one :document
>
>   accepts_nested_attributes_for :deliveries, :reject_if => lamda {
> |attributes| attributes['delivered_at'].blank? }
>   accepts_nested_attributes_for :document
>   ...
> end
>
> <%= form_for(@customer) do |f| %>
>   <%= f.fields_for :deliveries, @delivery do |delivery_fields %>
> <%= delivery_fields.input :delivered_at, :as => :hidden, :value =>
> Date.today %>
>   <% end %>
>   <%= f.fields_for :document do |doc_fields| %>
> <%= doc_fields.label :doc_type %>
> <%= doc_fields.text_field :doc_type %>
> <%= doc_fields.error :doc_type %>
>   <% end %>
>   <%= f.submit %>
> <% end %>

I've solved in this manner:

<%= form_for([@customer, @delivery]) do |f| %>
 <%= f.input :delivered_at, :as => :hidden, :value => Date.today %>
<%= fields_for @document do |doc| %>
 <%= doc.label :doc_type %>
 <%= doc.text_field :doc_type %>
<% end %>
<%= f.submit %>

I've used fields_for and not f.fields_for.
I've seen that there's no need to use accept_nested_attributes.

-- 
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.



Re: [Rails] one form for one model with nested resources.

2011-02-04 Thread Bente Pieck

http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html

Haven't tested it, but perhaps you try something like this:

class Customer
  has_many :deliveries
  has_one :document

  accepts_nested_attributes_for :deliveries, :reject_if =>  lamda { 
|attributes| attributes['delivered_at'].blank?}
  accepts_nested_attributes_for :document
  ...
end

<%= form_for(@customer) do |f| %>
  <%= f.fields_for :deliveries, @delivery do |delivery_fields %>
<%= delivery_fields.input :delivered_at, :as =>  :hidden, :value =>  
Date.today %>
  <% end %>
  <%= f.fields_for :document do |doc_fields| %>
<%= doc_fields.label :doc_type %>
<%= doc_fields.text_field :doc_type %>
<%= doc_fields.error :doc_type %>
  <% end %>
  <%= f.submit %>
<% end %>




On 03/02/11 17:52, Mauro wrote:

I have:

Customer
   has_many :deliveries
   has_one :document

Document
   belongs_to :customer

Delivery
   belongs_to :customer

route.rb has:

   resources :customers do
 resources :deliveries
   end


I already have customers in the database, I only have to add
deliveries and document to one customer.
I want to do with one single form.
Obviously this one doesn't work:

<%= form_for([@customer, @delivery]) do |f| %>
   <%= f.input :delivered_at, :as =>  :hidden, :value =>  Date.today %>
<%= f.fields_for :document do |doc| %>
   <%= doc.label :doc_type %>
   <%= doc.text_field :doc_type %>
  <%= doc.error :doc_type %>
<% end %>
<%= f.submit %>

It adds deliveries but not document.

Some advices?




--
best regards
Bente Pieck

--
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.



Re: [Rails] Re: Re: Configure logger, reopen class

2011-02-04 Thread Curtis



On Feb 3, 2011, at 2:16 PM, Albert Català  wrote:


Curtis wrote in post #979429:
On Feb 3, 2011, at 2:57 AM, Albert Catal   
wrote:





   super("ERROR>"+msg)
 end
end

this is in a file.rb in config/initializers/

and raises the error I said





Did you read my other response about class methods?


Yes but I'm still truing to do that, what do you mean? with

class << self

def error(msg)
  super("ERROR>"+msg)
 end

end # class methods Object.method_name

and where do I have to put this code?

Thanks for patience





Hey no worries - so

class A
 def self.error(msg)
  #comment - class method 'error'
  end
end

your first post had the right idea - only error is a method that  
belongs to the Logger instance - not the dynamic instance.


In A I have a method 'error' that belongs to the A instance.

A.new.error

Would result in a NoMethod on the execution of the code.

class A
  def error
  end
end

A.new.error

Will work now.

You can try this in irb.

You original code had a method that would go on a new instance of  
Logger - what you needed was a method 'error' on the Logger instance  
( refered to in object oriented programming as a the Logger Class)


When the error mentioned that the method could not be found - it is  
because the 'super' version of the method is actually in Logger the  
class method error .



Logger.info "assuming we are talking about the same logger•" 
 


--
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.



Re: [Rails] Required Ruby on Rails Developer ( Front End/ Back End ) / Boston, MA ( Immediate Interview )

2011-02-04 Thread jay gallivan
Greetings:

Thanks for contacting me. What is the rate on the project? What is the
business domain?

Regards,
Jay.

On Wed, Feb 2, 2011 at 11:06 AM, Chandan Kumar wrote:

>  Dear Partner,
>
>
>
> Please find our Urgent Direct Client Requirement and send me some matching
> profile ASAP along with the rate and contact details.
>
>
>
>
>
> *Position / Req. ID :*
>
> *Ruby on Rails Developer ( Front End/ Back End ) / Boston, MA *
>
> *Primary Skills :*
>
> Ruby on Rails, Java, Web Environment
>
> *Description :*
>
> Our Client is looking for Ruby on Rails Developer. For this position they
> are looking candidate who have experience on below skills:-
>
> * *
>
> · *Multithreading of system*
>
> · *Web environment, *
>
> · *Relational Databases (Our Client use PostgreSQL), *
>
> · *Scalability and performance issues, *
>
> · *Revision control System (SVN).*
>
> · *Ruby on Rails – 2-3 years of Experience required*
>
> * *
>
>
>
> *Rate: *DOE, *Job Type: *Full Time, *Total Exp: *7+Years, *US Exp: *3-5
> years, *Duration: *Long Term Project, *Number Of Openings: *6, *Location:
> *Boston, MA
>
> *FACE TO FACE INTERVIEW IS MUST BUT AFTER TELEPHONIC*
>
>
>
> *Best Regards***
>
> *Chandan Kumar*
>
> *Quantronix, Inc***
>
> *www.quantronix.com ***
>
> *Phone No: 203 718 2011*
>
> *Email: recruit...@quantronix.com*
>
> *2969 Whitney Avenue**, Hamden, CT 06518** *
>
>
>
> P  *Reduce, Reuse, Recycle. Go GREEN *and please consider our environment
> before printing this email
>
>
>
> --
> 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.
>

-- 
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: TinyMCE editor

2011-02-04 Thread frankblizzard
might be a stupid question but did you include jquery explicitly in
your application.html.erb file
or whatever layout you are using? or just the :defaults?
because jquery doesn't get included by default

On 4 Feb., 07:59, kirti parihar  wrote:
> hi...
> I m newbie in RoR and  working on rails 3.
> Actually i m using tiny_mce plugin in my application and following the steps
> mentioned in this linkhttps://github.com/kete/tiny_mce,
> No doubt this is working absolutely fine in application but the other Jquery
> applied to the application is not working (example dynamically add and
> remove textboxes is not working)
> Dont know why it is so...
> If anyone knows then help me...
>
> Thanks
> kirti

-- 
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: Where to set utf-8 encoding

2011-02-04 Thread Paul Bergstrom
Phillip wrote in post #979611:
> http://blog.grayproductions.net/articles/ruby_19s_three_default_encodings

Great article. Informative and educational. Thank 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 
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 get rid of nil values in session?

2011-02-04 Thread Frederick Cheung


On Feb 4, 7:46 am, arunmehta  wrote:
> When I inspect the session hash, it shows me lots of entries that I
> have assigned a nil value to at some point. Is that taking up a lot of
> space?
>
> What is a good way to get rid of these useless entries?
>
You should probably track down where they are getting set.

Fred

> I am generally trying to reduce the size of my session hash. Is there
> a note with tips about this?
>
> Thanks,
> Arun

-- 
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: Ignore attr_accessible in seed file

2011-02-04 Thread Frederick Cheung


On Feb 4, 8:51 am, Markus Proske  wrote:
> On Thursday, February 3, 2011 11:58:23 PM UTC+1, Ruby-Forum.com User wrote:
>
> > Here's one way I found a quick Google search:
>
> >http://stackoverflow.com/questions/4838716/how-to-avoid-the-validatio...
>
> Thank you. I've already been there and this works but I was looking for a
> more global setting for all entries in the seed file. Is there really no
> other way?
>
Bit hacky but you could override
remove_attributes_protected_from_mass_assignment or overwrite the
attribute containing the list of protected attributes

Fred

-- 
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 set default_scope for the whole application?

2011-02-04 Thread pepe
> > I want is to set
> > default_scope :order => 'created_at ASC'
> > for all models on default. How is that done?

If you want to do this no matter what I think there should be a way to
do it at initialization. If you are using Rails 2.3.x you might be
able to do it in 'new_rails_defaults.rb' in folder config/
initizializers. I have not used Rails 3 yet so I don't know where I
would make the change in that version, there is a comment in
'new_rails_defaults.rb' saying that the contents of that script will
be default in Rails 3 and the script can be removed when Rails is
upgraded to 3 so maybe the script will not run, but you can always try
anyway.

-- 
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 transfer a javascript value into a symbol used in Ruby on Rails

2011-02-04 Thread Frederick Cheung


On Feb 4, 10:05 am, Mohnish G j  wrote:

> > Fred
>
> Hi Fred,
>
> it doesn't work. I have tried it out earlier also.

What happens? What do the parameters look like in the log file?

Fred
>
> --
> 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] bundle show

2011-02-04 Thread hari
$ bundle show mysql
/home/bhas/.rvm/gems/ruby-1.9.2-p136/gems/mysql-2.8.1

but when I run

$ rake db:migrate
(in /home/bhas/projects/schapp)
rake aborted!
no such file to load -- mysql-2.8.1
/home/bhas/projects/schapp/Rakefile:4:in `'
(See full trace by running task with --trace)


Please help.

-- 
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] How to work with Database in routes? Rails 3

2011-02-04 Thread redhotberry
Hello. How to check presence of object in DB in routes? If object
exists in DB - rais app shows its page, if not - it redirects to 404.
I know that it's possible to do all this logic in controller but i
would to know how to do it in routes.

-- 
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: Where to set utf-8 encoding

2011-02-04 Thread Phillip
http://blog.grayproductions.net/articles/ruby_19s_three_default_encodings

On Feb 4, 3:09 am, Paul Bergstrom  wrote:
> I added this to the top of environment.rb
>
> Encoding.default_external = 'UTF-8'
>
> Seems to have done the trick. At least I think so.
>
> --
> 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: How to transfer a javascript value into a symbol used in Ruby on Rails

2011-02-04 Thread Mohnish G j
Frederick Cheung wrote in post #979561:
> On Feb 4, 1:36am, Mohnish G j  wrote:
>> > need to though. When the form containing the calendar gets submitted,
>> create button. It's taking a NULL value currently and not the value
>> selected via the plugin date interface.
>>
>
> According to the examples at http://2007.electronicholas.com/calendar,
> you can do calendar_date_select_tag :publishing_date
>
> Fred

Hi Fred,

it doesn't work. I have tried it out earlier also.

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Testing and application

2011-02-04 Thread Hans
thanks for all good advices
I will follow them and start by getting the Rspec book and will then
use cucumber and finally rspec for any new or refactored code

On 3 Feb, 16:15, yurokle  wrote:
> I totally agree with Peter, you should implement cucumber tests at
> first, and then if you'll still have some time, you should implement
> RSpec tests also.
> The Rspec book isn't so big, I read it twice completely and 3 time
> more some single chapters, it's really a great book, don't miss the
> chapters which aren't technical, they contain a lot answers on concept
> questions what to test and how,.
>
> I met the same problem, as you, Hans ~ 3-4 months ago. I was trying to
> find some patterns of testing already written applications, but didn't
> find anything.
> So I started from noting on the paper which user scenarios do I have
> in my app, and then implemented ~ 60% scenarios coverage by cucumber
> for all good and bad cases.
> It took really a lot of time ~ 0.3 - 0.5 of app implementing time,
> especially a lot of time at first takes implementing of basic cucumber
> steps, but later when you already have a good base, the work goes much-
> much faster.
>
> So My Advice is:
> 1) "The RSpec book (it covers Cucumber also)
> 2) Implement Cucumber tests
> 3) Implement RSpec tests
> 4) Continue app implementing in BDD manner.
>
> P.S. You can check also for Gerard Maszaros "xUnit Test Patterns"
> book, this one is really big, and it's really difficult to read it
> completely, but it contains also a lot of answers on concept question,
> like what is mock, stub, double in testing theory, when you should
> each one of these and a lot of other things.
>
> On Feb 3, 5:00 pm, Peter Bell  wrote:
>
> > I'd start with cucumber and capybara to verify key stories. That way you at 
> > least have smoke tests for going through the system. If you have time after 
> > that, put in some lower level rspec tests - mainly around areas of 
> > complexity.
>
> > Then every time you add a feature, change a piece of code or get a bug, add 
> > a test. That way you'll end up with good code coverage in the areas of the 
> > app that need it (the parts with complexity, bugs or which you touch a lot) 
> > for the smallest practical investment of time.
>
> > You'll want to use factory girl or something similar for creating stuff 
> > like user objects for your tests. The rspec book is good, but big. Rails 
> > testing prescriptions isn't bad. There are also lots of blog postings, so 
> > I'd just get started and then google when you run into something.
>
> > Best Wishes,
> > Peter
>
> > On Feb 3, 2011, at 4:22 AM, Hans Marmolin wrote:
>
> > > Hi
> > > I have a rails application with no tests.
> > > I decided early not to use a TDD or to have any automatic tests as I am 
> > > the only develope, as I tested it manually and as I thought many of the 
> > > proposed test procedures could be substituted by just looking at the code.
> > > However I was wrong. When the code became complex enough and when 
> > > refactoring becomes important automatic testing seems necessery.
>
> > > Most guidelines, tutorials and discussions about testings concerns 
> > > application that  is to be implemented, while I have an application that 
> > > is already running.
>
> > > How to proceed, with a large application,manually tested, that one would 
> > > like to add automatic tests to.  ?
>
> > > What framwork should I use to add tests (I can not apply TDD to a already 
> > > implemented application) -- rails test framework?, rspec?, shoulda? or 
> > > some other ?
> > > Rspec seems to have a simpler syntax and focus on a higher level of 
> > > testings.
>
> > > What should be tested first?
>
> > > Should I test features that I alredy have tested manually?
>
> > > Any other advices ?
>
> > > Would appreciate any help
>
> > > 
> > > Hans Marmolin
> > > St: Larsgatan 50, 58224 Linköping, Sweden
> > > Phone: +46708371202
>
> > > --
> > > 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 
> > > athttp://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
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] Problem with test-unit 2.1.2 and self.startup method

2011-02-04 Thread Szymon Nowak
Hey,

I've got strange problem with self.startup method - it's supposed to be 
executed only once, but it seems like it's not the case. This log is from 
running a single test file:

"Running AS::TestCase.startup"
"Running AS::TestCase.startup"
"Running AS::TestCase.startup"
"Running AS::TestCase.startup"
"Running AS::TestCase.startup"
"Running PayoutTest.startup before calling AS::TestCase.startup"
"Running AS::TestCase.startup"

I've got self.startup method defined in ActiveSupport::TestCase class and in 
PayoutTest class, which calls super. It seems that AC::TestCase.startup is 
called 5 times before PayoutTest.startup method is called... Any idea what 
can be wrong?

I'm using Ruby 1.9.2, test-unit 2.1.2 and Rails 3.0.4.rc1.

Cheers,
Szymon

-- 
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: Ignore attr_accessible in seed file

2011-02-04 Thread Markus Proske
On Thursday, February 3, 2011 11:58:23 PM UTC+1, Ruby-Forum.com User wrote:
>
> Here's one way I found a quick Google search:
>
>
> http://stackoverflow.com/questions/4838716/how-to-avoid-the-validation-callbacks-and-attr-accessible-effects-during-the-s
>
Thank you. I've already been there and this works but I was looking for a 
more global setting for all entries in the seed file. Is there really no 
other way?

Markus 

-- 
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: Where to set utf-8 encoding

2011-02-04 Thread Paul Bergstrom
I added this to the top of environment.rb

Encoding.default_external = 'UTF-8'

Seems to have done the trick. At least I think so.

-- 
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 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.