Philip Cortes | 1 Aug 2010 02:21

Check_Box Validation Script doesn't work

Hello,

I'm a complete newbie to Rails, and am trying to jump in and add
something to my application.  I'm trying to have users check a checkbox,
accepting our terms of service, prior to registering.  I have validation
scripts written to ensure that the user first and last name fields
aren't left blank (validates_presence_of), and  also have scripts doing
password length checks.  I cannot for the life of me figure out how to
make the checkbox validation work.

I have entered the following into my user.rb model :

class User < ActiveRecord::Base
  validates_acceptance_of :eula, :message => "must be agreed to"

My other validations are there as well - example:

validates_presence_of     :first_name

I have entered the following in the signup.html.erb file :

  <%= check_box :user, :eula %>
  <label for="terms_of_service">By checking this box I am agreeing to
Meeteor's <a href="../sites/terms_of_service"> Terms of
Service</a></label>

I entered this script down near the bottom of the page right next to the
signup button.  My other validation scripts read code from the following
block :

(Continue reading)

Rolf Pedersen | 1 Aug 2010 02:53
Picon

Problem with non-ascii characters in forms: "incompatible character encodings: UTF-8 and ASCII-8BIT"

Hi

First off, I'm using Ruby 1.9.1p378 and Rails 2.3.8.

I was creating a minimal application to test handling of Norwegian special characters when I bumped into this strange problem...

I have a simple Car model with fields maker:string and model:string.
For the controller I planned to just have an index action do all the work:

class CarsController < ApplicationController
  def index
    if request.post?
      <at> car = Car.new(params[:car])
      <at> car.save
    end
    <at> cars = Car.find(:all)
  end
#  def create
#    <at> car = Car.new(params[:car])
#    <at> car.save
#    redirect_to :action => :index
#  end
end

The corresponding view lists all car models and displays a form to support the addition of new car models:
<h1>Cars</h1>
<table>
  <th>maker</th><th>model</th>
  <% <at> cars.each do |car| %>
    <tr>
      <td><%= car.maker %></td>
      <td><%= car.model %></td>
    <td>
  <% end %>
</table>

<% form_for(:car, :url => { :action => "index" }) do |f| %>
  <p>
    <%= f.label :maker %>
    <%= f.text_field :maker %>
  </p>
  <p>
    <%= f.label :model %>
    <%= f.text_field :model %>
  </p>
  <p>
    <%= f.submit 'Add' %>
  </p>
<% end %>

Now, this works fine..... until I submit special characters in one of the fields.
If I for example write "Dodge" and "Børnout" in the form fields, I get an error like this:

Encoding::CompatibilityError in Cars#index

Showing app/views/cars/index.html.erb where line #19 raised:

incompatible character encodings: UTF-8 and ASCII-8BIT

Extracted source (around line #19):

16: </p>
17: <p>
18: <%= f.label :model %>
19: <%= f.text_field :model %>
20: </p>
21: <p>
22: <%= f.submit 'Add' %>

But, the entry is added correctly to the database anyway, so if I just reload http://localhost:3000/cars, I do see the new entry.
OK, I thought... I've read quite a few places that there have been (and still are) various issues with support for Unicode in the different Ruby/Rails version combinations, so I figured that I just didn't have the best combination for this.
But then I temporarily built a new application by using generate scaffold, and it all works fine there.
After some trying and failing I discovered that if I (in my original solution) changed the form_for :url option to :action => "create" and added a create action in the controller file (commented out in the above controller source), it works with special characters and all.

So the only difference is that the form posts the data to the create action instead of the index action, and then it works.

I just don't get it! :o/

Anyone has an explanation to offer?
Would be much appreciated! :o)

Kind regards,
Rolf

--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Srdan Dukic | 1 Aug 2010 02:59
Picon

App won't recognise action_mailer_tls plugin

Hi,

I'm running Ubuntu 10.04 and am trying to send mail through my Gmail account for testing. I've installed the 'action_mailer_tls' plugin using the 'sudo gem install action_mailer_tls' plugin and can confirm that it installed successfully:

$ gem list --local

*** LOCAL GEMS ***

action_mailer_tls (1.1.3)
actionmailer (2.3.8)
actionpack (2.3.8)
activerecord (2.3.8)
activeresource (2.3.8)
activesupport (2.3.8)
authlogic (2.1.5)
rack (1.1.0)
rails (2.3.8)
rake (0.8.7)


In my application, I have inserted the following line in environment.rb:

config.gem "action_mailer_tls"

However, when I try to run 'script/server' I get the following error:

=> Rails 2.3.8 application starting on http://0.0.0.0:3000
no such file to load -- action_mailer_tls
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
...
...
Missing these required gems:
  action_mailer_tls 

You're running:
  ruby 1.8.7.249 at /usr/bin/ruby1.8
  rubygems 1.3.5 at /home/srdan/.gem/ruby/1.8, /var/lib/gems/1.8

Run `rake gems:install` to install the missing gems.

When I try running 'rake gems:install' I get no output and trying to start up the application again gives the same error. Why is the application not recognising the gem, when it is clearly installed?

Thank you

--
Srđan Đukić

--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Guo Yangguang | 1 Aug 2010 04:07

Re: how to understand callback and validate_associated

Thanks,fred.

-- 
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@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Guo Yangguang | 1 Aug 2010 05:56

handle exception in ajax call

sorry to bother to help me again.I invoke create action using ajax.The
variant and it's associations are put in a transaction.When both are
saved successfully,render create_variant using ajax.When anyone
unsuccessfully,rallback all the saving manipulation,rescue exception,and
render the new_variant using ajax,which has <%=error_messages_for
:variant-%> to display invalidations.
But when inputtings are invalid,i always get something like
attachment.It seems the exception is not handled at all,the error
meassages are not displayed as expected.can you help me? thank!
###############
     def create
       <at> product=Product.find_by_id(params[:product_id])
       <at> variant=Variant.new(params[:variant])
       <at> product.variants<< <at> variant
       <at> base_option=Option.new(:name=>params[:base_option][:name],:price=>0)
       <at> variant.options<< <at> base_option
       Variant.transaction do
        begin
           <at> variant.options.each{|option|option.save!}
           <at> variant.save!
          flash.now[:notice]='variant created successfully'
          render :action=>:create_variant,:layout=>false
        rescue Exception
          raise
          render :action=>:new_variant,:layout=>false
        end
       end
     end
##############

Attachments:
http://www.ruby-forum.com/attachment/4896/2.jpg

-- 
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@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Nick | 1 Aug 2010 06:49

Re: about ActiveRecord callback

On 2010-07-31 18:11, Guo Yangguang wrote:
> So my following understanding is right?
> if exception occurs when saving the existing record, or when executing
> after_update method body,both the existing record's saving and sql
> statements in the after_update method body are all rollbacked?

Right.  If you see something different, it would be a bug.
-- 
Nick

--

-- 
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@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

rodrigo3n | 1 Aug 2010 07:03
Picon
Gravatar

Admin interface for Rails?

Hello folks, I am currently working on a project that has to deliver
an admin interface like the Django's one, I wanna know if you know/
recommend any gem or plugin for that.

Cheers,
Rodrigo Alves Vieira

--

-- 
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@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Guo Yangguang | 1 Aug 2010 07:26

Re: about ActiveRecord callback

thanks,Nick.But can you help me the question about "handle exception in 
ajax call"?

-- 
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@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Fernando Perez | 1 Aug 2010 11:22

Re: Problem with non-ascii characters in forms: "incompatible character encodings: UTF-8 and ASCII-

Hahaha!

Search the list, and you'll notice that people have already fallen into 
this trap.

Wait 'til Rails 3 AND Ruby 1.9.2 get released to jump to Rails+Ruby1.9

Stick to Rails 2.3.8 and Ruby 1.8.7 until then.
-- 
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@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

hywhy | 1 Aug 2010 11:52

question about sqlite3-ruby on linux


first sorry for my poor english.I have a question about sqlite3-ruby on
linux.
I have compiled and installed the ruby 1.9.1, sqlite3 and sqlite3-ruby on
redhat enterprise version.
but when I use irb and import the sqlite3 module, it will throw the error,
what's the matter. 

irb(main):001:0> require 'sqlite3'
LoadError: libsqlite3.so.0: cannot open shared object file: No such file or
directory -
/usr/ruby1.9.1/lib/ruby/gems/1.9.1/gems/sqlite3-ruby-1.3.1/lib/sqlite3/sqlite3_native.so
        from
/usr/ruby1.9.1/lib/ruby/gems/1.9.1/gems/sqlite3-ruby-1.3.1/lib/sqlite3.rb:6:in
`require'
        from
/usr/ruby1.9.1/lib/ruby/gems/1.9.1/gems/sqlite3-ruby-1.3.1/lib/sqlite3.rb:6:in
`rescue in <top (required)>'
        from
/usr/ruby1.9.1/lib/ruby/gems/1.9.1/gems/sqlite3-ruby-1.3.1/lib/sqlite3.rb:2:in
`<top (required)>'
        from (irb):1:in `require'
        from (irb):1
        from /usr/ruby1.9.1/bin/irb:12:in `<main>'

thanks 

----hywhy
-- 
View this message in context: http://old.nabble.com/question-about-sqlite3-ruby-on-linux-tp29317264p29317264.html
Sent from the RubyOnRails Users mailing list archive at Nabble.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@...
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.


Gmane