Ok, I just fixed it and it was a weird solution. I had to login to my
deploy user and check out the project, but when I did that it prompted
me if I wanted to add the host to the list of known_hosts, and I said
yes so I guess all I had to do was add itself to the list of
known_hosts.
On Dec 31, 10:58 pm, Mike C <snib...@gmail.com> wrote:
> I'm about ready to deploy my app so I decided to create a testapp to
> deploy just so I can learn how to use capistrano for deployment. I'm
> running Ruby 1.8.7 with Rails 3.0.3, capistrano 2.5.19 and git 1.7.3.2
> with gitosis. Everything is going to be hosted on the same machine
> (git and the app, so the app will be deployed on the same server as
> the git repo).
>
> Long story short, when I set my deploy_via to :remote_cache I get a
> host key auth failed, but when I set it to :copy everything works. If
> I understand correctly, I need to create a key for the user I use to
> deploy the app. I did that and I added it to the gitosis-admin but it
> didn't seem to work. I really want to use :remote_cache though, so any
> insights into this problem are highly 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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I'm about ready to deploy my app so I decided to create a testapp to
deploy just so I can learn how to use capistrano for deployment. I'm
running Ruby 1.8.7 with Rails 3.0.3, capistrano 2.5.19 and git 1.7.3.2
with gitosis. Everything is going to be hosted on the same machine
(git and the app, so the app will be deployed on the same server as
the git repo).
Long story short, when I set my deploy_via to :remote_cache I get a
host key auth failed, but when I set it to :copy everything works. If
I understand correctly, I need to create a key for the user I use to
deploy the app. I did that and I added it to the gitosis-admin but it
didn't seem to work. I really want to use :remote_cache though, so any
insights into this problem are highly 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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
very thank you.
i know how to test observer now.
but i can't understand why observer can't run in spec?
On Sat, Jan 1, 2011 at 1:49 AM, djangst <djangst@gmail.com> wrote:
> Does this help?
>
> http://stackoverflow.com/questions/33048/how-would-you-test-observers-with-rspec-in-a-ruby-on-rails-application
>
> On Dec 31, 5:06 am, soldier <8863...@gmail.com> wrote:
>> but when i use rspec , the observer can't run in, it's never step in.
>
> --
> 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+unsubscribe@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+unsubscribe@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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I figured it out. I had an error in one of the model callbacks and
was overwriting the data that had just been read from the DB.
Thanks,
Jim
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Dec 31, 2010, at 3:15 AM, Jim wrote:
> My Article model has one boolean field called "draft". I'm using
> sqlite3 and rails 3.0.3. The boolean column (which was created
> with :boolean) is storing 'true' and 'false' as 't' and 'f' in the
> database, and the queries appear to be working fine for both cases.
> The problem is that when I look at the draft attribute on the query
> result objects, it is always "true":
>
> @articles = Article.where(:draft => false) # returns the correct
> rows
> logger.debug(@articles[0].draft) # will show 'true'
maybe try logger.debug( @articles[0].draft? ) since that's more
explicitly asking "is this true-ish?"
Walter
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Fri, Dec 31, 2010 at 3:52 PM, Jimish Jobanputra <lists@ruby-forum.com> wrote:
> I am trying to parse a URL of this format
>
> http://example.com/links?deal_id=161&url=http://another_example.com/index.php?route=product/product&product_id=275
>
> I need to get 2 params
>
> deal_id and url
>
> However, in the above example, if I do params[:url], then I get
> "http://another_example.com/index.php?route=product/product"
>
> product_id=275 is dropped on the floor as its considered another
> params....
>
> CGI:escape for url is not an option since I have no choice in what I am
> being passed...
>
> Any ideas?
1) Parse the entire query string yourself instead of using the params
hash
2) Explicitly retrieve params['product_id'] and (re)build the url param
as you need it in the controller.
3) Fix the request (as in #2) in a Rack middleware filter.
4) Tell the "no-choice" source of these malformed unescaped URLs
to read the damn RFCs :-)
HTH,
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
There is a value in the column which means true, you need to create a method in the model to translate that for you.
--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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
More clues:
root@ubuntu-VirtualBox:/home/adminuser/Desktop/rubygems-1.4.0# rvm
package install zlib
Fetching zlib-1.2.5.tar.gz to /usr/local/rvm/archives
Extracting zlib-1.2.5.tar.gz to /usr/local/rvm/src
Configuring zlib in /usr/local/rvm/src/zlib-1.2.5.
Compiling zlib in /usr/local/rvm/src/zlib-1.2.5.
Installing zlib to /usr/local/rvm/usr
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Trying to understand why I get this error. I tried to follow
instructions at :
http://www.hackido.com/2010/12/install-ruby-on-rails-on-ubuntu.html
------------
Here is some more info on the issue:
------------
root@ubuntu-VirtualBox:/home/adminuser/Desktop/rubygems-1.4.0# rvmsudo
gem install rails --no-rdoc --no-ri
ERROR: Loading command: install (LoadError)
no such file to load -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand
root@ubuntu-VirtualBox:/home/adminuser/Desktop/rubygems-1.4.0# gem list
ERROR: Loading command: list (LoadError)
no such file to load -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::ListCommand
root@ubuntu-VirtualBox:/home/adminuser/Desktop/rubygems-1.4.0# which gem
/usr/local/rvm/rubies/ruby-1.9.2-p136/bin/gem
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
root@ubuntu-VirtualBox:/home/adminuser/Desktop/rubygems-1.4.0# ruby -v
ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-linux]
root@ubuntu-VirtualBox:/home/adminuser/Desktop/rubygems-1.4.0# ruby
./setup.rb
/home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems/source_index.rb:62:in
`installed_spec_directories': undefined method `path' for Gem:Module
(NoMethodError)
from
/home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems/source_index.rb:52:in
`from_installed_gems'
from /home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems.rb:914:in
`source_index'
from
/home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems/gem_path_searcher.rb:98:in
`init_gemspecs'
from
/home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems/gem_path_searcher.rb:13:in
`initialize'
from /home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems.rb:873:in
`new'
from /home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems.rb:873:in
`searcher'
from /home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems.rb:495:in
`find_files'
from /home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems.rb:1034:in
`load_plugins'
from
/home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems/gem_runner.rb:84:in
`<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from ./setup.rb:25:in `<main>'
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I get a error using Ubuntu 10.10 with Ruby 1.9.2p136 and trying to
manually install the GEM package. I am thrown for a loop on this one.
What is wrong?
---------------------------
root@ubuntu-VirtualBox:/home/adminuser/Desktop/rubygems-1.4.0# ruby
./setup.rb
/home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems/source_index.rb:62:in
`installed_spec_directories': undefined method `path' for Gem:Module
(NoMethodError)
from
/home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems/source_index.rb:52:in
`from_installed_gems'
from /home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems.rb:914:in
`source_index'
from
/home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems/gem_path_searcher.rb:98:in
`init_gemspecs' from
/home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems/gem_path_searcher.rb:13:in
`initialize'
from /home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems.rb:873:in
`new'
from /home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems.rb:873:in
`searcher'
from /home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems.rb:495:in
`find_files'
from /home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems.rb:1034:in
`load_plugins'
from
/home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems/gem_runner.rb:84:in
`<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from ./setup.rb:25:in `<main>'
root@ubuntu-VirtualBox:/home/adminuser/Desktop/rubygems-1.4.0# ruby -v
ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-linux]
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I get the exact same error using Ubuntu 10.10 with Ruby 1.9.2p136 . I
am thrown for a loop on this one. What is wrong?
root@ubuntu-VirtualBox:/home/adminuser/Desktop/rubygems-1.4.0# ruby
./setup.rb
/home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems/source_index.rb:62:in
`installed_spec_directories': undefined method `path' for Gem:Module
(NoMethodError)
from
/home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems/source_index.rb:52:in
`from_installed_gems'
from /home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems.rb:914:in
`source_index'
from
/home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems/gem_path_searcher.rb:98:in
`init_gemspecs'
from
/home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems/gem_path_searcher.rb:13:in
`initialize'
from /home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems.rb:873:in
`new'
from /home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems.rb:873:in
`searcher'
from /home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems.rb:495:in
`find_files'
from /home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems.rb:1034:in
`load_plugins'
from
/home/adminuser/Desktop/rubygems-1.4.0/lib/rubygems/gem_runner.rb:84:in
`<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from ./setup.rb:25:in `<main>'
root@ubuntu-VirtualBox:/home/adminuser/Desktop/rubygems-1.4.0# ruby -v
ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-linux]
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hello,
I am trying to parse a URL of this format
I need to get 2 params
deal_id and url
However, in the above example, if I do params[:url], then I get
"http://another_example.com/index.php?route=product/product"
product_id=275 is dropped on the floor as its considered another
params....
CGI:escape for url is not an option since I have no choice in what I am
being passed...
Any ideas?
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
(Apologies if this ends up being a duplicate. I've been battling
Google Groups and don't see the OP on the site so I'm going to try
once more.)
My Article model has one boolean field called "draft". I'm using
sqlite3 and Rails 3.0.3. The boolean column (which was created
with :boolean) is storing 'true' and 'false' as 't' and 'f' in the
database, and the queries appear to be working fine for both cases.
The problem is that when I look at the draft attribute on the query
result objects, it is always "true":
@articles = Article.where(:draft => false) # returns the correct
rows
logger.debug(@articles[0].draft) # will show 'true'
I know that Ruby treats 'f' as true, but I'm assuming Rails will
convert it to false as part of the mapping. Why isn't it working?
Thanks,
Jim
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
well. adding
Mime::Type.register "text/*", :html
to config/initializers/mime_types.rb works but it gives a warning on
startup
actionpack-3.0.3/lib/action_dispatch/http/mime_type.rb:98: warning:
already initialized constant HTML
Seems like rails doesn't want us to extend the definition of an HTML
mime type. Probably for the better, any suggestions. I could ping
thunderstone and have them fix their crawler but I'm wondering if
there is a better way Rails an handle this case.
On Dec 31, 4:47 pm, Tony Primerano <tony.primer...@gmail.com> wrote:
> The thunderstone crawler (http://search.thunderstone.com/texis/
> websearch/about.html) sends the folliowing HTTP accept header when
> requesting pages
>
> Accept: text/*, application/javascript, application/x-javascript
>
> This results in a "Missing template" exception
>
> text/* is valid. How do I tell my rails app to treat this as rhtml by
> default instead of returning a 500?
>
> Missing template [controller]/[method] with
> {:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml], :formats=>[:"text/
> *", :js], :locale=>[:en, :en]}
>
> I'll post a response if I figure it out
> Tony Primerano
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
What is the easiest way to dump a selection of data for someone else
to import? If XML, what is the cleanest way to accomplish this?
As a hobby, I wrote a workout logging program that now has about 2000
users. From time to time, someone asks me to export their workout
records to another application. I finally decided to set up an XML
resource for this. But I don't want to put a lot of effort into it.
Right now, my controller looks like this:
def person_workouts_xml
@person = Person.find(params[:id])
@workouts = @person.workouts
end
My .builder template looks like this:
xml.instruct! :xml, :version=>"1.0"
xml.workouts{
for workout in @workouts
xml.workout(workout.to_xml)
end }
I also tried the builder template like this:
xml.workouts(@workouts.to_xml)
Both methods work, but the output is rather ugly, and I doubt others
will want to slog through it. Should I be using to_xml in combination
with the builder this way? Is there a better, cleaner, simpler way?
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
It looks like the .profile is loaded when no .bash_profile exists, but
that the .bash_profile supercedes .profile when it is found, preventing
it from being loaded. Adding source ~/.profile will fix the problem, yet
as John Merlino has made a good point about the two I have switch
everything over to .bash_profile
Thanks John
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
You need to create a .bash_profile in root directory, which is usually
your name. Then once .bash_profile exists, if you use textmate, do: mate
.bash_profile and add this line:
source ~/.profile
And then it should work. That's becuase .profile is what contains the
path and you are just pointing to it from .bash_profile.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I have a Javascript accordion.
The accordion starts in the completely closed state.
The accordion opens up to a bunch of links. If the user clicks on a
link it takes the user to a document that I have created and display.
What I want is for the user to be able to click on the back button and
have the accordion remember its state.
I'm not asking for Javacript help. I'm just wondering how in Rails I
can
detect that "I went to the document and that I am returning from the
document".
There is no username so I guess the info needs to go in the session
data.
Suggestions on how to preserve state across a "back' would be
appreciated.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
The thunderstone crawler (http://search.thunderstone.com/texis/
websearch/about.html) sends the folliowing HTTP accept header when
requesting pages
Accept: text/*, application/javascript, application/x-javascript
This results in a "Missing template" exception
text/* is valid. How do I tell my rails app to treat this as rhtml by
default instead of returning a 500?
Missing template [controller]/[method] with
{:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml], :formats=>[:"text/
*", :js], :locale=>[:en, :en]}
I'll post a response if I figure it out
Tony Primerano
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
We are using the rpx gem in our rails 3 program. I uninstalled the plugin and tried to login and I get the error above. Ideas?? I did restart the server.
--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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi djangst,
When model validation rules result in errors, those errors are
basically made available to you as an ordered hash where the keys are
symbols of the attribute names and the values are strings/arrays of
the error(s) for the attribute.
So if you had some model foo.rb:
class Foo < ActiveRecord::Base
validates_presence_of :bar
...
HUMAN_ATTR_NAMES = {
:bar => "Bar Biz Baz",
...
}
def self.human_attribute_name(attr, options={})
HUMAN_ATTR_NAMES[attr.to_sym] || super
end
...
end
and tested in console:
$ ./script/rails console
Loading development environment (Rails 3.0.3)
> foo = Foo.create({})
=> #<Foo id: nil, ...
> foo.errors.any?
=> true
> foo.errors
=> {:bar=>["can't be blank"], ....
> Foo.human_attribute_name(:bar)
=> "Bar Biz Baz"
So, if in some controller where you call @foo.create or @foo.save that
results in validation errors, then in the resulting view you could
grab those errors and do whatever you want with them, like:
...
<% if @foo.errors.any? %>
<% @foo.errors.each do |attr, errs| %>
<div ...>
<% attr_label = Foo.human_attribute_name(attr) %>
<% err_msg = (errs.is_a?(Array)) ? errs.join(' and ') : errs %>
<span ...><%= attr_label %> <%= err_msg %></span>
<% end %>
</div>
<% end %>
...
It sounds like in your case, for each attr in your form, you'd want to
check if that attr had a validation err, and if so render that attr's
error(s) along with the attr's label and form element.
Note also that if you instead are calling @foo.create! or @foo.save!
in your controller, you'd get at that same errors ordered hash via
ActiveRecord::RecordInvalid:
$ ./script/rails console
...
> begin ; foo2 = Foo.create!({}) ; rescue ActiveRecord::RecordInvalid => rie ; rie.record.errors ; end
=> {:bar=>["can't be blank"], ....
Cheers,
Jeff
On Dec 31, 6:07 am, djangst <djan...@gmail.com> wrote:
> The main problem is with styling adjacent elements, in this case a
> label. Or you might want to style a div that encloses an input and its
> label.
>
> On Dec 31, 4:13 am, ivanpoval <ivanpo...@gmail.com> wrote:
>
>
>
> > Hi,
> > Here is a couple of things that I found myself doing for customizing
> > the error messages:
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I changed my laptop for a one with windows 7. I installed rails 2.3.5,
postgres-pr 0.6.3, mongrel 1.1.5 and copied my app that was previously
on a win xp PC. When I launched my server and connected to my app, I had
the following error :
Status: 500 Internal Server Error
uninitialized constant PostgresPR::Connection::UNIXSocket
C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:105:in
`const_missing'
C:/Ruby187/lib/ruby/gems/1.8/gems/postgres-pr-0.6.3/lib/postgres-pr/connection.rb:167:in
`establish_connection'
I resolved this problem by looking at my database.yml file. The
development section was like that :
development:
adapter: postgresql
encoding: UTF8
database: my_database_development
pool: 5
username: xxxxx
password: xxxxx
# Connect on a TCP socket. Omitted by default since the client uses a
# domain socket that doesn't need configuration. Windows does not have
# domain sockets, so uncomment these lines.
#host: localhost
#port: 5432
I just uncommented the last 2 lines (as is recommended...) :
host: localhost
port: 5432
and it worked just fine. It worked fine on the win xp machine with these
lines commented, though.
Hope this will be of some help if you've ran into this kind of problem.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, Dec 30, 2010 at 11:58 PM, Tom <tomjmalone@gmail.com> wrote:
> I am creating a rails app that is a gui wraping a restful web service
> that uses a websso for authentication. This websso sets a series of
> headers that I need to pass from the request to the
> ActiveResource.find methods. As this is stuff like username etc it is
> going to be different for each request. I can find examples on how to
> set headers for all requests not just one.
"set" or do you actually mean "get" ?
If you need to *read* headers from a request you should do that in
your controller; unsurprisingly they're in a 'request.headers' array :-)
HTH,
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 31 December 2010 15:53, Alpha Blue <lists@ruby-forum.com> wrote:
> Hi everyone,
>
> I decided it might be nice if someone after me had an easier time
> understanding a little bit about rails engines and how they work. I've
> created a rails example engine called "baby_dove" that you can use to
> work with that is heavily commented for your benefit. It's located
> here:
>
> https://github.com/elricstorm/baby_dove
>
> Rails Engines are a fantastic addition with Rails 3.x and I hope you
> enjoy the writeup.
Thanks for that Alpha. Engines are on my list of things to learn
about, I have bookmarked your link and it will be the first of my
visitations when I get started.
> Take care and Happy New Year.
and yourself.
Cheers
Colin
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Doh! Thanks, that was the problem, obviously.
On Dec 30, 6:12 pm, Philip Hallstrom <phi...@pjkh.com> wrote:
> On Dec 30, 2010, at 3:17 PM, byron appelt wrote:
>
> > I am trying to get reject_if to work using a method name instead of a
> > Proc. However I cannot seem to get this to work. A simplified version
> > of my model code is shown below. The problem is that I keep getting an
> > "undefined method `call' for :not_wired?:Symbol" error. I am using
> > Rails 2.3.4. Can anyone give me an idea of what might be going on
> > here?
>
> 2.3.4 doesn't allow a symbol. Proc only. So either upgrade or switch over to using a Proc...
>
> -philip
>
>
>
>
>
>
>
>
>
> > class DeviceConfiguration < ActiveRecord::Base
>
> > has_one :obd_configuration
> > accepts_nested_attributes_for :obd_configuration, :reject_if
> > => :not_obd?
>
> > has_one :wired_configuration
> > accepts_nested_attributes_for :wired_configuration, :reject_if
> > => :not_wired?
>
> > def not_obd?(attrs)
> > !device_type.name.eql?("obd")
> > end
>
> > def not_wired?(attrs)
> > !device_type.name.eql?("wired")
> > end
>
> > end
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I'm trying to get this plugin to work for me. I'm having the
following issue when I try to render a pdf (/fancy_things/45.pdf )..
Any suggestions?
Thanks!
ERROR:
Started GET "/fancy_things/45.pdf" for 192.168.66.1 at Fri Dec 31
10:59:07 -0500 2010
Processing by OrdersController#show as PDF
Parameters: {"id"=>"45"}
***************WICKED***************
Completed in 4ms
ArgumentError (wrong number of arguments (1 for 0)):
app/controllers/orders_controller.rb:20
app/controllers/orders_controller.rb:9:in `show'
Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/
action_dispatch/middleware/templates/rescues/_trace.erb (4.8ms)
Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/
action_dispatch/middleware/templates/rescues/_request_and_response.erb
(30.6ms)
Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/
action_dispatch/middleware/templates/rescues/diagnostics.erb within
rescues/layout (49.7ms)
CONTROLLER:
def show
respond_to do |format|
format.html { render 'show' }
format.pdf do
@example_text = "some text"
render :pdf => "file_name",
:template => 'offers/show.pdf.erb',
:layout => 'pdf',
:footer => {
:center => "Center",
:left => "Left",
:right => "Right"
}
end
end
end
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Martin, go visit this new link I created which will provide a link to
an example rails engine I created. It should help answer all of your
questions.
http://www.ruby-forum.com/topic/775710
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi everyone,
I decided it might be nice if someone after me had an easier time
understanding a little bit about rails engines and how they work. I've
created a rails example engine called "baby_dove" that you can use to
work with that is heavily commented for your benefit. It's located
here:
https://github.com/elricstorm/baby_dove
Rails Engines are a fantastic addition with Rails 3.x and I hope you
enjoy the writeup.
Take care and Happy New Year.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Something at the Rack level, maybe?
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
The main problem is with styling adjacent elements, in this case a
label. Or you might want to style a div that encloses an input and its
label.
On Dec 31, 4:13 am, ivanpoval <ivanpo...@gmail.com> wrote:
> Hi,
> Here is a couple of things that I found myself doing for customizing
> the error messages:
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Dec 30, 11:00 pm, Woody Peterson <woody.peter...@gmail.com> wrote:
> We've been using find_in_batches to reduce memory usage, and recently
> noticed one of our more intensive background processes had a huge
> memory footprint (600mb+) and was getting killed by our memory
> monitor. We were unable to reproduce this in development, and after
> investigation, the culprit is query_cache. Wrapping the task in
> ActiveRecord::Base#uncached kept the task stable (~200mb), and it's
> not hard to imagine why. Looping over thousands of items while eager
> loading many more likely grows the cache to huge amounts, which seems
> counter to the use case for find_in_batches.
>
Were you manually turning on query cache in your background processes?
(I was trying to think why I hadn't been bitten by this before and
remembered that the query cache is turned on via an around filter by
default, so doesn't affect scripts run by hand, daemon processes etc)
> So first of all, this is an FYI. Beyond that, all the ways in which we
> use find_in_batches would be aversely affected by the query_cache;
> sure, it *might* make a query faster, but it *definitely* will grow in
> memory, as you are expected to use it across thousands of records.
> Given that find_in_batches' use case is to reduce memory when
> searching across thousands of records, should it not be default
> behavior to disable query cache for find_in_batches operations?
Seems sensible. I'm not sure how tight the scope of your disabling
should be, ie should query caching be forced off for the contents of
the block? The block might also be doing lots of stuff that is
inherently pointless to cache, but equally it might not.
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
you can use attr_accessible.
On Fri, Dec 31, 2010 at 11:06 AM, Amar Jampa <lists@ruby-forum.com> wrote:
> What is Mass Assignment?
> Can you give me a clear idea about that with an example?
>
> --
> 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+unsubscribe@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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I read the guide and api and i created Observer on model, she can run
on rails console of test env.
but when i use rspec , the observer can't run in, it's never step in.
some good man help me, please. i debug it use one day and one night, i
can't sleep in today night unless i solve it.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 31 December 2010 02:52, Prasad B. <lists@ruby-forum.com> wrote:
> Hi thank you very much ,you got my point and understand my thinking you
> suggest good idea
I've no idea who you're thanking, as you didn't quote any previous message.
> ,i am new to ruby on rails so please suggest rails
> tags also for array of check boxes.
googling for "ruby rails tutorial" will give you lots of results. I
recall that you've already been pointed at the documentation for
associations, and it might be good for you to get a book to work
through - "Agile Web Development With Rails" is highly recommended.
> How serialize array of that hobbies
> object and store in database
You can use the "serialize" method on a model.... but that's *not*
what you want to solve your problem - you want to use associations...
it may have been mentioned already.
Sorry for sounding terse... got a plane to catch :-)
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi,
Here is a couple of things that I found myself doing for customizing
the error messages:
1 alter the result of the error_messages_for helper (for example to
use gsub to make some small updates);
2 redefine the "ActionView::Base.field_error_proc" to your own
procedure;
3 add some additional YAML code to your locales file to specify the
different error message.
--
Hope it was helpful, Ivan Povalyukhin
On Dec 30, 1:56 pm, djangst <djan...@gmail.com> wrote:
> Does anybody know a good way to completely customize validation
> output? I've tried a number of options but can only get partway there.
>
> For example I'd like to style not only the affected form input but
> also its label, and provide a message (common to many apps). This has
> been problematic, as the input is referenced internally by 'html_tag'
> and at that point its associated label is out of scope:
>
> http://edgeguides.rubyonrails.org/active_record_validations_callbacks...
>
> I've added the message using this method but can't get at the label.
>
> I've also created an auto-labeling form builder (http://
> edgeguides.rubyonrails.org/form_helpers.html#customizing-form-
> builders) but the error handling still only grabs the input itself
> after the form has been built (i.e., it doesn't view my custom labeled
> input as a sort of composite control).
>
> I can accomplish this in the view conditionally by checking
> @instance.errors on a per-field basis, but this seems clunky. And if I
> do that, doesn't all the validation stuff still fire internally,
> burning cycles on something I don't use?
>
> There must be a good way to automate this.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Yes, this is a very handy feature of ActiveRecord in Rails!
Let me summarize here some related methods that come up to my mind:
- changed? predicate if any attributes have been updated
- name_changed? described above
- name_was restores the previous value
- name_change [old_value, new_value]
- changed [list_of_changed_attributes]
- changes [hash_of_changed_attributes_with_values]
--
Thanks, Ivan Povalyukhin
On Dec 30, 7:08 am, David Kahn <d...@structuralartistry.com> wrote:
> On Thu, Dec 30, 2010 at 7:59 AM, Greg Ma <li...@ruby-forum.com> wrote:
> > Frederick Cheung wrote in post #971451:
> > > On Dec 30, 1:40pm, Greg Ma <li...@ruby-forum.com> wrote:
> > >> Hi,
> > >> Is it possible to know in a callback to know which attributes were
> > >> updated?
> > >> I want to do stuff only if one attribute has been updated.
>
> > > The changed and changes methods lists changed attributes. There are
> > > also invididual predicate methods, eg name_changed?
>
> > > Fred
>
> > Thanks I didn't know that one!
>
> Yeah me too, that's very cool, I actually have the perfect place to apply it
> today
>
>
>
>
>
>
>
>
>
> > --
> > 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+unsubscribe@googlegroups.com<rubyonrails-talk%2Bunsubscrib e@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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 31 December 2010 02:52, Prasad B. <lists@ruby-forum.com> wrote:
> Hi thank you very much ,you got my point and understand my thinking you
> suggest good idea ,i am new to ruby on rails so please suggest rails
> tags also for array of check boxes.How serialize array of that hobbies
> object and store in database
In order to understand better the basics of RoR I suggest you work
through some tutorials and guides. Start with working through all the
Rails Guides and also railstutorial.org (which is a free tutorial when
used online). Then you will be able to answer most of your own
questions. Come back and ask again if you still have problems.
Colin
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
My Article model has one boolean field called "draft". I'm using sqlite3 and rails 3.0.3. The boolean column (which was created with :boolean) is storing 'true' and 'false' as 't' and 'f' in the database, and the queries appear to be working fine for both cases. The problem is that when I look at the draft attribute on the query result objects, it is always "true":
@articles = Article.where(:draft => false) # returns the correct rows
logger.debug(@articles[0].draft) # will show 'true'
I know that Ruby treats 'f' as true, but I'm assuming rails will convert it to false as part of the mapping. Why isn't it working?
Thanks,
Jim
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I'd love to see/hear the approach to design and build an engine. How
can I use an engine to share code among like projects? Can I decompose
a larger project into engines? What are the considerations and
pitfalls? Mantras for design?
On Dec 30, 8:07 pm, Alpha Blue <li...@ruby-forum.com> wrote:
> Okay, it took me a few hours but I completed my first engine for rails
> 3.1 edge. I found several very handy articles and start points in case
> anyone else wants to learn more about rails engines. Here are the links
> and resources I found:
>
> http://piotrsarnacki.com/2010/09/14/mountable-engines/http://edgeapi.rubyonrails.org/classes/Rails/Engine.htmlhttp://www.builtfromsource.com/2010/12/13/mountable-engines-in-rails-...https://github.com/krschacht/rails_3_engine_demo
>
> If anyone has questions, I'd be more than happy to walk you through the
> initial stress and labors. But, once you get it going, it feels really
> good.
>
> Thanks.
>
> --
> 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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I am creating a rails app that is a gui wraping a restful web service
that uses a websso for authentication. This websso sets a series of
headers that I need to pass from the request to the
ActiveResource.find methods. As this is stuff like username etc it is
going to be different for each request. I can find examples on how to
set headers for all requests not just one.
Does anyone know of a way of doing this
Thanks in advance
Tom
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I make two class job and step, its associate with
accepts_nested_attributes_for, has_many and belongs_to.
liks:
class Job < ActiveRecord::Base
has_many :steps, :dependent => :destroy
accepts_nested_attributes_for :steps
validate :job_validate , :on => :create
def job_validate
p "job validate"
end
end
class Step < ActiveRecord::Base
belongs_to :job
# here just test if called this validates_presence_of
validates_presence_of :name , :if => Proc.new { |step| p " step name
validates_presence_of" }
validate_on_create :step_validate
private
def step_validate
p self
p "step validate"
end
end
Tow migtations links:
class CreateJobs < ActiveRecord::Migration
def self.up
create_table :jobs do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :jobs
end
end
class CreateSteps < ActiveRecord::Migration
def self.up
create_table :steps do |t|
t.string :name
t.references :job
t.timestamps
end
end
def self.down
drop_table :steps
end
end
My problem is that when i testing them in script/console as follow:
shell:$ script/console
Loading shelllocal environment (Rails 2.3.5)
>> job = Job.new
=> #<Job id: nil, name: nil, created_at: nil, updated_at: nil>
>> job.steps.build
=> #<Step id: nil, name: nil, job_id: nil, created_at: nil,
updated_at: nil>
>> job.save
" step name validates_presence_of"
#<Step id: nil, name: nil, job_id: nil, created_at: nil, updated_at:
nil>
"step validate"
" step name validates_presence_of"
#<Step id: nil, name: nil, job_id: nil, created_at: nil, updated_at:
nil>
"step validate"
"job validate"
=> true
>>
As you see the "step validate" called two times.I think "step
validate" be called once is correct. I don't know why its called tow
times? Who can help me?
thank you !
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
What is Mass Assignment?
Can you give me a clear idea about that with an example?
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi thank you very much ,you got my point and understand my thinking you
suggest good idea ,i am new to ruby on rails so please suggest rails
tags also for array of check boxes.How serialize array of that hobbies
object and store in database
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
djangst wrote in post #971568:
> Sounds like you want a button with the onclick event. If so, there's
> (apparently) a helper for that:
>
> http://apidock.com/rails/ActionView/Helpers/JavaScriptHelper/button_to_function
@djangst: that's what I've ended up doing. Upon reflection, I'm
wondering why I thought everything needed to be in a form. Works fine
without it, as in:
<%= hidden_field_tag("authenticity_token", form_authenticity_token, :id
=> "authenticity_token") %>
<%= text_field_tag("raw_address", nil, :size => 96, :id =>
"raw_address") %>
<%= select_tag("occupants", options_for_select([0.5, ... 8.0], 2.0)) %>
<%= submit_tag("search for address", :onclick => "geocodeAddress()") %>
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Okay, it took me a few hours but I completed my first engine for rails
3.1 edge. I found several very handy articles and start points in case
anyone else wants to learn more about rails engines. Here are the links
and resources I found:
http://piotrsarnacki.com/2010/09/14/mountable-engines/
http://edgeapi.rubyonrails.org/classes/Rails/Engine.html
http://www.builtfromsource.com/2010/12/13/mountable-engines-in-rails-3-1-beta-getting-started/
https://github.com/krschacht/rails_3_engine_demo
If anyone has questions, I'd be more than happy to walk you through the
initial stress and labors. But, once you get it going, it feels really
good.
Thanks.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Sounds like you want a button with the onclick event. If so, there's
(apparently) a helper for that:
http://apidock.com/rails/ActionView/Helpers/JavaScriptHelper/button_to_function
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Dec 30, 2010, at 3:17 PM, byron appelt wrote:
> I am trying to get reject_if to work using a method name instead of a
> Proc. However I cannot seem to get this to work. A simplified version
> of my model code is shown below. The problem is that I keep getting an
> "undefined method `call' for :not_wired?:Symbol" error. I am using
> Rails 2.3.4. Can anyone give me an idea of what might be going on
> here?
2.3.4 doesn't allow a symbol. Proc only. So either upgrade or switch over to using a Proc...
-philip
>
> class DeviceConfiguration < ActiveRecord::Base
>
> has_one :obd_configuration
> accepts_nested_attributes_for :obd_configuration, :reject_if
> => :not_obd?
>
> has_one :wired_configuration
> accepts_nested_attributes_for :wired_configuration, :reject_if
> => :not_wired?
>
> def not_obd?(attrs)
> !device_type.name.eql?("obd")
> end
>
> def not_wired?(attrs)
> !device_type.name.eql?("wired")
> end
>
> end
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I need to do some JS processing in the client before contacting the
server (fwiw, this is for Google geocoding). The JS does its processing
and concocts a form to send back to the server. The latter part is
working fine.
In a previous iteration, I had the following. It activated the JS code
on any change to the text field, and worked (although now I know I
should use a text_field_tag rather than abusing a text_field):
<!-- a named field for the authenticity_token so initialize() can find
it. -->
<input type="hidden" id="authenticity_token" value="<%=
form_authenticity_token %>"\>
<!-- a field for the user to submit a raw address for geocoding -->
<div class="raw_address">
Type an address: <%= text_field :raw, :address, :onchange =>
"geocodeAddress()" %>
</div>
But now now that I've added another field, my instinct says to create a
form with a submit button. But I don't see how to create a form that
does NOT submit HTML when the submit button is pushed. Here's the
errant form. What I want is the "search" button to call
geocodeAddress() and nothing more.
<%= form_tag(premises_path, :remote => true) do %>
<%= hidden_field_tag("authenticity_token", form_authenticity_token,
:id => "authenticity_token") %>
<%= label_tag("address", "Type an address:") %>
<%= text_field_tag("raw_address", nil, :size => 96, :id =>
"raw_address") %>
<%= label_tag("occupants", "Occupants:") %>
<%= select_tag("occupants", options_for_select([0.5, ..., 8.0], 2.0))
%>
<%= submit_tag("search", :onchange => "geocodeAddress()") %>
<% end %>
Suggestions? (Perhaps I could just lose the form altogether...)
- ff
P.S.: Marnen, I know what you're thinking! :) I'll reframe it as UJS
once I get the basics working.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I am trying to get reject_if to work using a method name instead of a
Proc. However I cannot seem to get this to work. A simplified version
of my model code is shown below. The problem is that I keep getting an
"undefined method `call' for :not_wired?:Symbol" error. I am using
Rails 2.3.4. Can anyone give me an idea of what might be going on
here?
class DeviceConfiguration < ActiveRecord::Base
has_one :obd_configuration
accepts_nested_attributes_for :obd_configuration, :reject_if
=> :not_obd?
has_one :wired_configuration
accepts_nested_attributes_for :wired_configuration, :reject_if
=> :not_wired?
def not_obd?(attrs)
!device_type.name.eql?("obd")
end
def not_wired?(attrs)
!device_type.name.eql?("wired")
end
end
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
We've been using find_in_batches to reduce memory usage, and recently
noticed one of our more intensive background processes had a huge
memory footprint (600mb+) and was getting killed by our memory
monitor. We were unable to reproduce this in development, and after
investigation, the culprit is query_cache. Wrapping the task in
ActiveRecord::Base#uncached kept the task stable (~200mb), and it's
not hard to imagine why. Looping over thousands of items while eager
loading many more likely grows the cache to huge amounts, which seems
counter to the use case for find_in_batches.
So first of all, this is an FYI. Beyond that, all the ways in which we
use find_in_batches would be aversely affected by the query_cache;
sure, it *might* make a query faster, but it *definitely* will grow in
memory, as you are expected to use it across thousands of records.
Given that find_in_batches' use case is to reduce memory when
searching across thousands of records, should it not be default
behavior to disable query cache for find_in_batches operations?
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Greg Ma wrote in post #971151:
> ActiveRecord::StatementInvalid (Mysql::Error: Operand should contain 1
> column(s): SELECT * FROM `conversations` WHERE (conversations.started_by
> = 1 OR conversations.with = 1) AND (SELECT * FROM conversations c WHERE
> (c.started_by = 1 OR c.with = 1)) ORDER BY updated_at DESC)
Are you sure you really need :finder_sql? I didn't see anything here
that :condtions and :order couldn't handle.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Oren Golan wrote in post #923611:
> I had this issue after upgrading from ubuntu 9.10 (karmic) to 10.4
> (lucid).
> the solution was to libmysqlclient16-dev:
>
> sudo aptitude install libmysqlclient16-dev
As a Ubuntu user that did the trick for me.
Thanks a lot, Oren! Your decision to post this probably saved hours of
work for me.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Dec 30, 2:03 pm, Colin Law <clan...@googlemail.com> wrote:
> On 30 December 2010 20:34, Geo Manickam <geo...@hotmail.com> wrote:
>
>
>
>
>
>
>
>
>
>
>
> > On Dec 30, 2:06 am, Colin Law <clan...@googlemail.com> wrote:
> >> On 30 December 2010 04:32, Geo Manickam <geo...@hotmail.com> wrote:
>
> >> > I tried address still not able to display the address form.
>
> >> > <% person_form.fields_for :address do |address_form| %>
>
> >> Please don't top post, insert your comments at appropriate points in
> >> the previous message. It makes it easier to follow the thread.
> >> Thanks.
>
> >> What do you mean by not able to display address form? Is there an
> >> error shown? If not then what does the generated html look like? If
> >> the html is not correct then what is wrong with it?
>
> > basically the code inside the <%
> > person_form.fields_for :address do |address_form| %> is not
>
> It should be <%= person_form.... %>, I should have seen that before.
> Without the = it runs the code but does not put the result into the
> page.
thank you. :) my bad, consider this is resolved. It works for me
now.
>
> Colin
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 30 December 2010 20:21, Bo <bo@4peculiarpeople.com> wrote:
> Here are my tables
>
> patients
> id name
> 1 Bob
> 2 Carol
> 3 Ted
> 4 Reggie
>
> families
> family_id patient_id
> 1 1
> 1 2
> 2 3
> 2 4
>
> How do I structure the model associations so that I can
> @patient.family.patient[0].name?
I don't think you have the tables quite right.
I think you need Patient belongs_to family (so patients table will
have family_id field) and family has_many patients. Family needs only
id field (plus other stuff I assume).
Then you can use @patient.family.patients[0].name. Note patients is
plural here.
Colin
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 30 December 2010 20:34, Geo Manickam <geo_72@hotmail.com> wrote:
>
>
> On Dec 30, 2:06 am, Colin Law <clan...@googlemail.com> wrote:
>> On 30 December 2010 04:32, Geo Manickam <geo...@hotmail.com> wrote:
>>
>> > I tried address still not able to display the address form.
>>
>> > <% person_form.fields_for :address do |address_form| %>
>>
>> Please don't top post, insert your comments at appropriate points in
>> the previous message. It makes it easier to follow the thread.
>> Thanks.
>>
>> What do you mean by not able to display address form? Is there an
>> error shown? If not then what does the generated html look like? If
>> the html is not correct then what is wrong with it?
>
>
> basically the code inside the <%
> person_form.fields_for :address do |address_form| %> is not
It should be <%= person_form.... %>, I should have seen that before.
Without the = it runs the code but does not put the result into the
page.
Colin
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Does anybody know a good way to completely customize validation
output? I've tried a number of options but can only get partway there.
For example I'd like to style not only the affected form input but
also its label, and provide a message (common to many apps). This has
been problematic, as the input is referenced internally by 'html_tag'
and at that point its associated label is out of scope:
I've added the message using this method but can't get at the label.
I've also created an auto-labeling form builder (http://
edgeguides.rubyonrails.org/form_helpers.html#customizing-form-
builders) but the error handling still only grabs the input itself
after the form has been built (i.e., it doesn't view my custom labeled
input as a sort of composite control).
I can accomplish this in the view conditionally by checking
@instance.errors on a per-field basis, but this seems clunky. And if I
do that, doesn't all the validation stuff still fire internally,
burning cycles on something I don't use?
There must be a good way to automate this.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Bo Pritchard wrote in post #971530:
> Here are my tables
>
> patients
> id name
> 1 Bob
> 2 Carol
> 3 Ted
> 4 Reggie
>
> families
> family_id patient_id
> 1 1
> 1 2
> 2 3
> 2 4
>
> How do I structure the model associations so that I can
> @patient.family.patient[0].name?
By writing that method chain, you've just about answered your own
question. Try it!
>
> Make sense?
Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen@marnen.org
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thursday, December 30, 2010 1:38:18 PM UTC-5, Rails beginner wrote:
Hello
I have a problem. I cant figure out how to solve this authentication
problem with devise and i dont know if i should use a polymorphic
association in the models or STI.
I want to have 2 sign up pages. One for Teacher and one for Student. I
want the User table to store the login information(email,
password ...).
To get that working, your user class would inherit from ActiveRecord::Base, but your Student and Teacher class would inherit from User. No associations necessary.
class User < ActiveRecord::Base
class Student < User
class Teacher < User
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Dec 30, 2:06 am, Colin Law <clan...@googlemail.com> wrote:
> On 30 December 2010 04:32, Geo Manickam <geo...@hotmail.com> wrote:
>
> > I tried address still not able to display the address form.
>
> > <% person_form.fields_for :address do |address_form| %>
>
> Please don't top post, insert your comments at appropriate points in
> the previous message. It makes it easier to follow the thread.
> Thanks.
>
> What do you mean by not able to display address form? Is there an
> error shown? If not then what does the generated html look like? If
> the html is not correct then what is wrong with it?
basically the code inside the <%
person_form.fields_for :address do |address_form| %> is not
executed. i.e in the html page the label and edit boxes for address is
not displayed to the user. and if you look at view source you dont see
the html tags for them. if you move this code below inside fields_for,
no object information is displayed.
<%= debug(@person.address.attributes) %>
<%= debug(@person.address) %>
if there is better way (work around) to handle one-one mapping.
please let me know as well.
> Colin
>
>
>
>
>
>
>
>
>
> > thanks
> > Geo
>
> > On Dec 29, 8:34 am, Colin Law <clan...@googlemail.com> wrote:
> >> On 29 December 2010 07:52, Geo Manickam <geo...@hotmail.com> wrote:
>
> >> > I am new to rails, coming from .net. I am having the issue for 1:1
> >> > mapping nested model view the form will not render.
>
> >> > I have the code below. note the address object is created. I dont see
> >> > the label and text box. the person form render without any issue. the
> >> > debug works outside the fields_for.
>
> >> > Any help is appreciated
>
> >> > thanks
> >> > Geo
>
> >> > Model
> >> > ======
>
> >> > class Person < ActiveRecord::Base
> >> > has_one :address
> >> > accepts_nested_attributes_for :address
> >> > end
>
> >> > class Address < ActiveRecord::Base
> >> > belongs_to :person
> >> > end
>
> >> > Controller
> >> > ========
>
> >> > GET /people/new
> >> > # GET /people/new.xml
> >> > def new
> >> > @person = Person.new
> >> > @address = @person.address = @person.build_address
>
> >> > respond_to do |format|
> >> > format.html # new.html.erb
> >> > format.xml { render :xml => @person }
> >> > end
> >> > end
>
> >> > View: _form.html.erb
>
> >> > <%= form_for(@person) do |person_form| %>
> >> > <% if @person.errors.any? %>
> >> > <div id="error_explanation">
> >> > <h2><%= pluralize(@person.errors.count, "error") %> prohibited
> >> > this person from being saved:</h2>s
> >> > <ul>
> >> > <% @person.errors.full_messages.each do |msg| %>
> >> > <li><%= msg %></li>
> >> > <% end %>
> >> > </ul>
> >> > </div>
> >> > <% end %>
> >> > <div class="field">
> >> > <%= person_form.label :name %><br />
> >> > <%= person_form.text_field :name %>
> >> > </div>
> >> > <div class="field">
> >> > <%= person_form.label :email %><br />
> >> > <%= person_form.text_field :email %>
> >> > </div>
> >> > <div class="field">
> >> > <%= person_form.label :phone %><br />
> >> > <%= person_form.text_field :phone %>
> >> > </div>
> >> > <h1>outside</h1>
> >> > <%= debug(@person.address.attributes) %>
> >> > <%= debug(@person.address) %>
> >> > <% person_form.fields_for @address do |address_form| %>
>
> >> I think that should be :address not @address, it specifies the
> >> association to use.
>
> >> Colin
>
> >> > <h1>inside form</h1>
> >> > <div class="field">
> >> > <%= address_form.label :addressline1 %><br />
> >> > <%= address_form.text_field :addressline1 %>
> >> > </div>
> >> > <div class="field">
> >> > <%= address_form.label :addressline2 %><br />
> >> > <%= address_form.text_field :addressline2 %>
> >> > </div>
> >> > <% end %>
> >> > <div class="actions">
> >> > <%= person_form.submit %>
> >> > </div>
> >> > <% end %>
>
> >> > --
> >> > 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+unsubscribe@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+unsubscribe@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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.