Ruby on Rails Saturday, April 30, 2011

On Apr 30, 12:08 pm, Colin Law <clan...@googlemail.com> wrote:
> On 30 April 2011 16:40, amrit pal pathak <amritpalpath...@gmail.com> wrote:
>
> > This time i read scaffold tutorial very  carefully and finally try to
> > generate a form without using the scaffold(just used a controller and
> > view ).what i have done till now ,is as follow.Using rails 3.0.7.
>
> >                                 "rails generate controller posts
> > index"
>
> >  1) post_controller.rb
>
> >  class PostsController < ApplicationController
> >  def index
> >  @post=Post.new
>
> Why are you making a post in the index action?  This action should
> just be showing posts.
Yes Colin,this method was used for showing phosts.But this
is not a ard and fast rule that it must be used for showing posts.I
just doing experiment ,so used it for creating .
>
>
>
>
>
>
>
>
>
> >  end
> >  def create
> >  @post = Post.new(params[:post])
> >  respond_to do |format|
> >  end
> >  end
> >  end
>
> > 2)index.html.erb
>
> >  <h1>Posts#index</h1>
> > <p>Find me in app/views/posts/index.html.erb</p>
> > <%= link_to 'New Post', new_post_path%>
> > <%= form_for(@post) do |f| %>
> >  <div class="field">
> >    <%= f.label :name %><br />
> >    <%= f.text_field :name %>
> >  </div>
> >  <div class="field">
> >    <%= f.label :title %><br />
> >    <%= f.text_field :title %>
> >  </div>
> >  <div class="field">
> >    <%= f.label :content %><br />
> >    <%= f.text_area :content %>
> >  </div>
> >  <div class="actions">
> >    <%= f.submit %>
> >  </div>
> > <% end %>
>
> >                             i didnt create any model because i just
> > want to create a simple form first.so when i brower to "localhost:3000/
> > posts/index", it says
>
> >  "uninitialized constant PostsController::Post
>
> You have not told us which line is failing, but I guess it is the one that says
> @post=Post.new
> which says make a new Post object, but since you have not written the
> Post model how can it make a Post object?
>
> You cannot make a form for an object without defining the model first.
>  form_for( @post ) makes a form for the object @post.
@Colin and Walter
ok,model is must.Created a model as.
"rails generate model post" and then
did "rake db:create"(it created a database) and then "rake
db:migrate"(it created a posts tables in database).but now when i
browse to "locahost:3000/posts/index",it says


Showing /home/amrit/final/app/views/posts/index.html.erb where line #4
raised:
undefined method `posts_path' for #<#<Class:0xb67f7784>:0xb67f5560>

Thanks for support!!

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

Ruby on Rails

Hi, 


I'm starting to use Test::Unit to create unit tests for my Rails Applications/Plugins. I don't have much experience in Ruby Unit Testing. The problem is that the output report is very simple and it is very difficult to discover where is the error. Test::Unit does not show the line number of the error and the Stack Trace printed using the --trace option does not help either.

Here is the output of my test:

/home/gustavo/.rvm/rubies/ruby-1.9.2-p180/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /home/gustavo/.rvm/rubies/ruby-1.9.2-p180/bin/rake test:plugins --trace
Testing started at 23:18 ...
(in /home/gustavo/Projetos/seo_apps)
** Invoke test:plugins (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute test:plugins

NoMethodError: undefined method `score=' for #<Report:0xa1f269c>
1 tests, 0 assertions, 0 failures, 1 errors, 0 pendings, 0 omissions, 0 notifications
Test suite finished: 0.132010162 seconds
rake aborted!
Command failed with status (1): [/home/gustavo/.rvm/rubies/ruby-1.9.2-p180/...]
/home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:995:in `block in sh'
/home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:1010:in `call'
/home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:1010:in `sh'
/home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:1094:in `sh'
/home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:1029:in `ruby'
/home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:1094:in `ruby'
/home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/test_unit/testing.rake:26:in `block (2 levels) in define'
/home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:1112:in `verbose'
/home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/test_unit/testing.rake:11:in `block in define'
/home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:636:in `block in execute'
/home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:597:in `block in invoke_with_call_chain'
/home/gustavo/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2029:in `block (2 levels) in top_level'
/home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2029:in `block in top_level'
/home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2001:in `block in run'
/home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/home/gustavo/.rvm/rubies/ruby-1.9.2-p180/bin/rake:35:in `<top (required)>'
-e:1:in `load'
-e:1:in `<main>'

Process finished with exit code 1


Please, anyone have an idea of how to improve this error output??

Thanks in advance,
Gustavo

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

Ruby on Rails

Hi,
I'm using TinyMce with Rails 3 to input rich text.
when i enter a text into tinymce editor , the text is saved in the
database as <p> text </p> so a p tag is added to the text!!.
i need some help
Best 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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Ruby on Rails

I'm using csrf_meta_tag and the the headers appears correctly. The problem is when the athenticity_token has a plus sign and I use any of Jquery ajax function. So I tried to render the form_authenticity_token already escaped using that method above ( CGI.escape), but now the jquery ajax function works and this line isn't working anymore(when i click):


<%= link_to "Destroy", [@client, address], :confirm => 'Are you sure?', :method => :delete %>

After the click there ins't user session anymore:

Started POST "/clients/97" for 127.0.0.1 at Sat Apr 30 21:49:15 -0300 2011
  Processing by ClientsController#destroy as HTML
  Parameters: {"authenticity_token"=>"MCVYdvbAS4i7BiRaDZig9VHXbxltKo84BgDT%2BTL28%2BI%3D", "id"=>"97"}


When I use ajax is ok:

Started DELETE "/clients/118/files/9?authenticity_token=MCVYdvbAS4i7BiRaDZig9VHXbxltKo84BgDT%2BTL28%2BI%3D" for 127.0.0.1 at Sat Apr 30 21:48:52 -0300 2011
  Processing by ClippingsController#destroy as JS
  Parameters: {"authenticity_token"=>"MCVYdvbAS4i7BiRaDZig9VHXbxltKo84BgDT+TL28+I=", "id"=>"9,", "client_id"=>"118"}

In both cases the csrf header is exactly the same and i'm using the CGI.escape method.

Any help ?

Thanks,
Ernesto


On Sat, Apr 30, 2011 at 9:27 AM, Frederick Cheung <frederick.cheung@gmail.com> wrote:


On 30 Apr 2011, at 12:48, Ernesto Rocha <ernestorrocha@gmail.com> wrote:

I did some brute force only to test, like this:

<meta name="csrf-param" content="authenticity_token"/>
<meta name="csrf-token" content="<%= CGI.escape form_authenticity_token %>"/>

some characters are escaped, but now the link_to ... :method => delete is not working anymore (the user session is killed).

If I user URI.escape the plus sign is not escaped.


How are you adding the authenticity token to the URL ?  (Ps, rails has a csrf_meta_tag helper)

Fred
So, i'm still at point zero.

Thanks,
Ernesto


On Fri, Apr 29, 2011 at 6:10 AM, Frederick Cheung <frederick.cheung@gmail.com> wrote:


On Apr 29, 3:06 am, Ernesto Rocha <ernestorro...@gmail.com> wrote:
> How i escape it before the rails server process it ?
>
You'll need to do that at the point that you add the token to the link

Fred
> Thanks,
> Ernesto
>
> On Thu, Apr 28, 2011 at 4:58 AM, Frederick Cheung <
>
>
>
> frederick.che...@gmail.com> wrote:
>
> > On 28 Apr 2011, at 03:22, Ernesto Rocha <ernestorro...@gmail.com> wrote:
>
> > Guys,
>
> > I'm using some AJAX on my application, but when protect_from_forgery is on
> > sometimes it works and sometimes the user session is killed. Today i found
> > out why.
>
> > It happens the following:
>
> > The authenticity_token is sent correctly as you can see below,
>
> > Started DELETE
> > "/clients/118/files/20?authenticity_token=hoMH9/heaFWXWWy+aE1xKQcpf4xrLoVWG qkq0pzzwuo="
> > for 127.0.0.1 at Wed Apr 27 23:06:50 -0300 2011
>
> > but, next line on server is,
>
> > Processing by ClippingsController#destroy as JS
> >   Parameters: {"authenticity_token"=>"hoMH9/heaFWXWWy
> > aE1xKQcpf4xrLoVWGqkq0pzzwuo=", "id"=>"20,", "client_id"=>"118"}
>
> > as you can see, the plus sign ('+') turned into a white space. Once the
> > token doesn't match the user session is killed.
>
> > Is someone experiencing this ? Any help how to fix it ?
>
> > + in urls means space - if the token genuinely contains + then you need to
> > escape it before putting it in the URL.
>
> > Fred
>
> > Thanks,
> > Ernesto
>
> > --
> > 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.


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

Ruby on Rails

Colin Law wrote in post #995944:

> A cautionary note, a new version of Ubuntu (11.04) has just been
> released, which has made major changes to the UI and still has some
> teething issues. I would advise an Ubuntu newcomer to install 10.10
> for the moment (or even 10.04, the so called Long Term Support
> release).
>
> Colin

Nothing wrong with 10.04 or 10.10. However, running Gnome 2.32.1 on
11.04 Works great. You do not need to run Unity if you don't want to.

To the OP: Switch to Ubuntu - It *will* change your life.

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

Ruby on Rails

So I'm working on making my own heroku like stack. I have everything
except the hooks done now. My problem is that when I modify the Gemfile
to include MySQL2 if it's not already included, that I have to also
modify the Gemfile lock. Is there any library that can help with this?

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

Ruby on Rails

Colin Law wrote in post #995978:
> On 30 April 2011 18:00, David Mr. <lists@ruby-forum.com> wrote:
>>>
>>> So gamma[:C] is not a collection. Have a look at the Rails Guide on
>>
>>
>> attr_accessor :setA, :setB, :setAList, :setBList, :google
>
> First I would stick to the Rails conventions when naming things, so
> these should be set_a and so on.
>
>> before_create :setup_data
>> before_save :setup_data
>> def setup_data
>> debugger
>> setax = []
>> setbx = []
>
> You don't need the above as split will return an array
>
>> setax = setA.split(" ")
>> setbx = setB.split(" ")
>
> Are you saying that this method gets called ok but at this point,
> checked in the debugger, that setA has a sensible value but setax does
> not?
>
> It might help also if you explained whether any of the variables are
> db columns and which are just instance variables.
>
> Colin

As a quick reply...

Yes setA has a sensible -as expected value, but setax is always nil. I
can go to the debugger window and do setax = setA.split(" ") and then
setax has the proper value. How is that happening?

No, the variables are not the column names. The setA and setB data are
put into a table named 'searches' and column named 'terms'. The setA
and setB data are entered from a form using form_for.

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.

Ruby on Rails

Disclaimer: I really like the unix model of building products. 

 
The objection I've heard is specifically for
   - gems that depends on native packages in the repository
   - ruby, rvm and ruby that is already in the native package manager
The idea expressed was that dependencies are already explicitly defined by the native package manager, and that this is the clean way of resolving these dependencies. Another objection to installing your own version was that this bypasses the standard way for distributions to deploy security and bug-fixes.

From experience I think this view falls short because most dependencies are resolved by just calling bundler, and for those that are not you can just update your README with the proper information.

best,
Andy


are part of the package repository
On Sat, Apr 30, 2011 at 1:44 PM, UNIXgod <unixgod@rubyprogrammer.net> wrote:
On Sat, Apr 30, 2011 at 10:34 AM, Andreas Saebjoernsen
<andreas@digitalplaywright.com> wrote:
> The native package manager generally has very outdated ruby and rvm
> versions.
> I know this hurts unix purists, but it's your time and using rvm/gem/rails
> like most other people do will save you a lot of time.

rvm is a user sandbox. why would that hurt a purist?

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

Ruby on Rails

On 30 Apr 2011, at 20:04, bertly_the_coder <muchira@gmail.com> wrote:

> Hi guys, When I export data into a .csv file, it works perfectly. when
> I push the code to heroku, I get the following error:
> ActionView::Template::Error (can't convert Hash into String):
>
Are you running the same ruby version locally and in production ? This looks like it might be a ruby 1.8 vs 1.9 thing (the csv library was rewritten for 1.9)

Fred


> My helper to generate the csv is:
> def generate_csv
> csv_str = CSV.generate(:col_sep => ",") do |csv|
> Entrant.find(:all).each do |entrant|
> csv << [entrant.firstname, entrant.lastname, entrant.email,
> entrant.entrydate]
> end
> end
> end
>
> Is there any reason why I would get this error?
>
> Thanks in advance for your 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+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.

Ruby on Rails

On Sat, Apr 30, 2011 at 10:34 AM, Andreas Saebjoernsen
<andreas@digitalplaywright.com> wrote:
> The native package manager generally has very outdated ruby and rvm
> versions.
> I know this hurts unix purists, but it's your time and using rvm/gem/rails
> like most other people do will save you a lot of time.

rvm is a user sandbox. why would that hurt a purist?

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

Ruby on Rails

Hi guys, When I export data into a .csv file, it works perfectly. when
I push the code to heroku, I get the following error:
ActionView::Template::Error (can't convert Hash into String):

My helper to generate the csv is:
def generate_csv
csv_str = CSV.generate(:col_sep => ",") do |csv|
Entrant.find(:all).each do |entrant|
csv << [entrant.firstname, entrant.lastname, entrant.email,
entrant.entrydate]
end
end
end

Is there any reason why I would get this error?

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

Ruby on Rails


http://jeffkreeftmeijer.com/2011/acceptance-testing-using-capybaras-new-rspec-dsl/

A lot of people prefer RSpec for integration testing too. You only have to deal one test framework RSpec for all your testing. 

On Sat, Apr 30, 2011 at 9:35 AM, Phoenix Rising <polarisrising@gmail.com> wrote:
So I wanted to cook up a quick integration test for something, and I'm
using rspec.  I personally just don't like Cucumber - just a personal
preference, not a slam to the test framework at all - and wanted to
stick to just pure rspec.  So I dumped a quick spec file in spec/
reqests and ran it, and of course everything works.

But is this considered bad form, or a less-than-good practice?  I've
never written a "request spec" before, so I'm probably mis-using it,
but I'd sure like to hear of better ways to do an integration test
under rspec where I can just run something like 'rake
spec:integration' (which doesn't exist by default).  This was the best
I could do in a pinch, but wouldn't mind hearing some feedback on a
better way to do it in the future - WITHOUT cucumber, selenium,
webrat, capbybara, etc. etc. ;-)

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

Ruby on Rails

On 30 April 2011 18:00, David Mr. <lists@ruby-forum.com> wrote:
> Colin Law wrote in post #995918:
>> On 29 April 2011 22:40, David Mr. <lists@ruby-forum.com> wrote:
>>>>> /home/brad/Documents/blogazer/app/models/search.rb:201:in
>>> Here is the code from around line 201 in search.rb:
>>>
>>> def set_from_sources(sources)
>>>  final = Set.new
>>>   sources.each do |source|
>>
>> The error suggests that sources is not a collection
>>
>>>   p = Page.find_by_id source
>>>   h = YAML.load(p.data)
>>>   final.merge h.keys
>>>  end
>>>  final
>>> end
>>>
>>> Here is line 107 in search.rb:
>>> gamma[:D] = set_from_sources(gamma[:C]) - (txv[:a] + txv[:b])
>>
>> So gamma[:C] is not a collection.  Have a look at the Rails Guide on
>> debugging and find how to use ruby-debug to break into your code so
>> you can examine gamma.
>>
>> Colin
>
> OK.  I used debugger and found that 'setax and 'setbx' are nil instead
> of being assigned the strings in 'setA.split(" ")' and setB.split(" ").
>
> Using debugger I verified that setA has the proper string value entered
> at the form.
>
> Even if I change the code to setax = setA, setax is always nil.
>
> Does the fact that setA and setB are in the Attribute-Accessor list make
> a difference in the way I should assign other variables their value?
>
> Here is the code:
>
> class Search < ActiveRecord::Base
>  belongs_to :project
>  has_one :user, :through => :project
>
>  attr_accessor :setA, :setB, :setAList, :setBList, :google

First I would stick to the Rails conventions when naming things, so
these should be set_a and so on.

>  before_create :setup_data
>  before_save :setup_data
>  def setup_data
>   debugger
>    setax = []
>    setbx = []

You don't need the above as split will return an array

>    setax = setA.split(" ")
>    setbx = setB.split(" ")

Are you saying that this method gets called ok but at this point,
checked in the debugger, that setA has a sensible value but setax does
not?

It might help also if you explained whether any of the variables are
db columns and which are just instance variables.

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.

Ruby on Rails

Colin Law wrote in post #995918:
> On 29 April 2011 22:40, David Mr. <lists@ruby-forum.com> wrote:
>>>> /home/brad/Documents/blogazer/app/models/search.rb:201:in
>> Here is the code from around line 201 in search.rb:
>>
>> def set_from_sources(sources)
>> final = Set.new
>> sources.each do |source|
>
> The error suggests that sources is not a collection
>
>> p = Page.find_by_id source
>> h = YAML.load(p.data)
>> final.merge h.keys
>> end
>> final
>> end
>>
>> Here is line 107 in search.rb:
>> gamma[:D] = set_from_sources(gamma[:C]) - (txv[:a] + txv[:b])
>
> So gamma[:C] is not a collection. Have a look at the Rails Guide on
> debugging and find how to use ruby-debug to break into your code so
> you can examine gamma.
>
> Colin

OK. I used debugger and found that 'setax and 'setbx' are nil instead
of being assigned the strings in 'setA.split(" ")' and setB.split(" ").

Using debugger I verified that setA has the proper string value entered
at the form.

Even if I change the code to setax = setA, setax is always nil.

Does the fact that setA and setB are in the Attribute-Accessor list make
a difference in the way I should assign other variables their value?

Here is the code:

class Search < ActiveRecord::Base
belongs_to :project
has_one :user, :through => :project

attr_accessor :setA, :setB, :setAList, :setBList, :google
before_create :setup_data
before_save :setup_data
def setup_data
debugger
setax = []
setbx = []
setax = setA.split(" ")
setbx = setB.split(" ")

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.

Ruby on Rails

Quoting David Kahn <dk@structuralartistry.com>:
> On Sat, Apr 30, 2011 at 8:14 AM, Jeffrey L. Taylor <ror@abluz.dyndns.org>wrote:
>
> > How can download of files be tested? The processing of the file is being
> > tested okay, but I don't know how to simulate the controller call.
> >
>
> What are you using to test? This is a bit off your topic as it sounds like
> you are writing controller specific tests. I used to do that, but in the
> last year I have started convering my ui and views heavily with testing and
> since doing this I find that I can achieve reasonably also testing the
> controller actions. I am sure some will argue against this but in the
> interest in time and quality I think I get more bang for my time covering
> how the user will use my ui. That said, I use rspec with capybara (steak)
> and using capybara, if there is a download link, I just click the link and
> then look at the page.body which gives me the content of the downloaded
> file.
>
> I know you should be able to do so in a controller spec/test also, should be
> something like calling a get. I am not sure what your method is but if it
> has multiple formats then you would have to specify the format in a
> parameter I think, or do something like "get '/controller/action/file.pdf"
> or something like that. I would google for 'rails test file download', it
> looks like you will have some results you can at least piece together.
>

Oops, I have the directions backwards. I need to simulate/test upload of a
file. The user is uploading their RSS feeds in an OPML file (typically
exported from Google Reader). I expected this to be an obscure question, so I
didn't Google it. It isn't. There are several answers on Stack Overflow and
elsewhere. I sucessfully used the answer at the URL below. Note, this has
changed in Rails 3. There is a link to the Rails 3 answer in the footnote to
the first answer.

Jeffrey

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

Ruby on Rails

On 30 April 2011 16:40, amrit pal pathak <amritpalpathak1@gmail.com> wrote:
> This time i read scaffold tutorial very  carefully and finally try to
> generate a form without using the scaffold(just used a controller and
> view ).what i have done till now ,is as follow.Using rails 3.0.7.
>
>                                 "rails generate controller posts
> index"
>
>  1) post_controller.rb
>
>  class PostsController < ApplicationController
>  def index
>  @post=Post.new

Why are you making a post in the index action? This action should
just be showing posts.

>  end
>  def create
>  @post = Post.new(params[:post])
>  respond_to do |format|
>  end
>  end
>  end
>
> 2)index.html.erb
>
>  <h1>Posts#index</h1>
> <p>Find me in app/views/posts/index.html.erb</p>
> <%= link_to 'New Post', new_post_path%>
> <%= form_for(@post) do |f| %>
>  <div class="field">
>    <%= f.label :name %><br />
>    <%= f.text_field :name %>
>  </div>
>  <div class="field">
>    <%= f.label :title %><br />
>    <%= f.text_field :title %>
>  </div>
>  <div class="field">
>    <%= f.label :content %><br />
>    <%= f.text_area :content %>
>  </div>
>  <div class="actions">
>    <%= f.submit %>
>  </div>
> <% end %>
>
>                             i didnt create any model because i just
> want to create a simple form first.so when i brower to "localhost:3000/
> posts/index", it says
>
>  "uninitialized constant PostsController::Post

You have not told us which line is failing, but I guess it is the one that says
@post=Post.new
which says make a new Post object, but since you have not written the
Post model how can it make a Post object?

You cannot make a form for an object without defining the model first.
form_for( @post ) makes a form for the object @post.

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.

Ruby on Rails

On Apr 30, 2011, at 11:40 AM, amrit pal pathak wrote:

> This time i read scaffold tutorial very carefully and finally try to
> generate a form without using the scaffold(just used a controller and
> view ).what i have done till now ,is as follow.Using rails 3.0.7.
>
> "rails generate controller posts
> index"
>
> 1) post_controller.rb
>
> class PostsController < ApplicationController
> def index
> @post=Post.new
> end
> def create
> @post = Post.new(params[:post])
> respond_to do |format|
> end
> end
> end
>
> 2)index.html.erb
>
> <h1>Posts#index</h1>
> <p>Find me in app/views/posts/index.html.erb</p>
> <%= link_to 'New Post', new_post_path%>
> <%= form_for(@post) do |f| %>
> <div class="field">
> <%= f.label :name %><br />
> <%= f.text_field :name %>
> </div>
> <div class="field">
> <%= f.label :title %><br />
> <%= f.text_field :title %>
> </div>
> <div class="field">
> <%= f.label :content %><br />
> <%= f.text_area :content %>
> </div>
> <div class="actions">
> <%= f.submit %>
> </div>
> <% end %>
>
> i didnt create any model because i just
> want to create a simple form first.so when i brower to "localhost:
> 3000/
> posts/index", it says
>
> "uninitialized constant PostsController::Post
>
> Please somebody help to resolve it
>
> Thanks
>
>

You must have a model if you're going to call Post.new. That's where
that 'new' method happens. The model tells the controller what fields
it should initialize, which tells the view that the default values are
whatever they are, etc. It's MVC, not VC!

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

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

Ruby on Rails

This time i read scaffold tutorial very carefully and finally try to
generate a form without using the scaffold(just used a controller and
view ).what i have done till now ,is as follow.Using rails 3.0.7.

"rails generate controller posts
index"

1) post_controller.rb

class PostsController < ApplicationController
def index
@post=Post.new
end
def create
@post = Post.new(params[:post])
respond_to do |format|
end
end
end

2)index.html.erb

<h1>Posts#index</h1>
<p>Find me in app/views/posts/index.html.erb</p>
<%= link_to 'New Post', new_post_path%>
<%= form_for(@post) do |f| %>
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :title %><br />
<%= f.text_field :title %>
</div>
<div class="field">
<%= f.label :content %><br />
<%= f.text_area :content %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>

i didnt create any model because i just
want to create a simple form first.so when i brower to "localhost:3000/
posts/index", it says

"uninitialized constant PostsController::Post

Please somebody help to resolve it

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

Ruby on Rails

On 30 April 2011 00:13, David Kahn <dk@structuralartistry.com> wrote:
>
>
> On Fri, Apr 29, 2011 at 5:05 PM, Mauro <mrsanna1@gmail.com> wrote:
>>
>> On 29 April 2011 23:52, David Kahn <dk@structuralartistry.com> wrote:
>> >
>> >
>> > On Fri, Apr 29, 2011 at 4:41 PM, Mauro <mrsanna1@gmail.com> wrote:
>> >>
>> >> I have a Shop model with some attributes:
>> >>
>> >>  role_number   :integer(10)
>> >>  role_date     :date
>> >>  name          :string(255)
>> >>  ssn           :string(255)
>> >>  nationality   :string(255)
>> >>  address       :string(255)
>> >>  number        :string(255)
>> >>  website       :string(255)
>> >>  district      :integer(10)
>> >>  sector        :string(255)
>> >>  square_meters :integer(131089)
>> >>  duaap         :integer(10)
>> >>  description   :string(255)
>> >>  state         :string(255)
>> >>  notes         :text
>> >>
>> >> I want to create a form for searching on one field or on two fields or
>> >> on three fields...............or on all fields.
>> >> There is a gem that facilitate this work?
>> >> I'm thinking about meta_search, what do you think about?
>> >
>> > I just used MetaSearch for the first time last month and love it. I
>> > found it
>> > very easy to work with and quite powerful.
>>
>> What solution do you adopt?
>> A form with all fields in it?
>
> If you use MetaSearch, it helps you build your form -- see the readme:
> https://github.com/ernie/meta_search

If I want to search base on values on all fields I must create a long form.
I've found http://www.2dconcept.com/jquery-grid-rails-plugin it seems
nice, what do you think about?

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

Ruby on Rails

Type. I meant the tips I've used when installing rails on Linux, not Windows.

On Sat, Apr 30, 2011 at 8:34 AM, Andreas Saebjoernsen <andreas@digitalplaywright.com> wrote:
I think the tips I've used when installing rails on Windows is this:
  1. Do not use the native package manager to install ruby, rvm and gems.
    • Install your own custom rvm, ruby and rails.
    • The native package manager generally has very outdated ruby and rvm versions.
    • I know this hurts unix purists, but it's your time and using rvm/gem/rails like most other people do will save you a lot of time.
  2. Use the railsready script to automate  installing custom rvm, ruby and rails versions.
I think that's it.

Btw, Rails 3 works best with Ruby 1.9.2. You may bump into bugs with Ruby 1.8.7 that can be hard to detect and debug. So type 'ruby --version' after installing ruby to make sure that you're running a recent version.

Best,
Andy

On Sat, Apr 30, 2011 at 7:32 AM, David Kahn <dk@structuralartistry.com> wrote:


On Sat, Apr 30, 2011 at 7:36 AM, Ron Tsoref <chieff7@gmail.com> wrote:
First of all, thank you all for your suggestions.
I think I'll finally do the switch from Windows to Ubuntu. I wanted to do it for a while, and I think it's a good time to do it now.

Once I install Ubuntu, what should I do next?


Google for instructions on installing Ruby on Rails on Ubuntu, then if you run in to trouble post back here. But basically, you want to run the package installer (apt-get) to install ruby. Once ruby is installed you will be able to use ruby gems to install the rest you need. It is probably too much for right now but at some point you shold look at using rvm which helps you manage different versions of ruby on the same machine and to allow different installations of rails configurations for your different projects.
 

On Thu, Apr 28, 2011 at 8:02 PM, Bryan Crossland <bacrossland@gmail.com> wrote:
On Wed, Apr 27, 2011 at 8:26 AM, Chief <chieff7@gmail.com> wrote:
What is the best and easiest way of running Ruby on Rails on a Windows
7 machine?

I really want to learn Rails, but I haven't found any easy way of
installing it on Windows 7.


Install a VM of Ubuntu or Linux and develop on that. Avoid installing Ruby or Ruby on Rails on Windows like the plague. You will be in for more trouble that it is worth trying to get everything you need to work on Windows.

B.

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


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

Ruby on Rails

I think the tips I've used when installing rails on Windows is this:

  1. Do not use the native package manager to install ruby, rvm and gems.
    • Install your own custom rvm, ruby and rails.
    • The native package manager generally has very outdated ruby and rvm versions.
    • I know this hurts unix purists, but it's your time and using rvm/gem/rails like most other people do will save you a lot of time.
  2. Use the railsready script to automate  installing custom rvm, ruby and rails versions.
I think that's it.

Btw, Rails 3 works best with Ruby 1.9.2. You may bump into bugs with Ruby 1.8.7 that can be hard to detect and debug. So type 'ruby --version' after installing ruby to make sure that you're running a recent version.

Best,
Andy

On Sat, Apr 30, 2011 at 7:32 AM, David Kahn <dk@structuralartistry.com> wrote:


On Sat, Apr 30, 2011 at 7:36 AM, Ron Tsoref <chieff7@gmail.com> wrote:
First of all, thank you all for your suggestions.
I think I'll finally do the switch from Windows to Ubuntu. I wanted to do it for a while, and I think it's a good time to do it now.

Once I install Ubuntu, what should I do next?


Google for instructions on installing Ruby on Rails on Ubuntu, then if you run in to trouble post back here. But basically, you want to run the package installer (apt-get) to install ruby. Once ruby is installed you will be able to use ruby gems to install the rest you need. It is probably too much for right now but at some point you shold look at using rvm which helps you manage different versions of ruby on the same machine and to allow different installations of rails configurations for your different projects.
 

On Thu, Apr 28, 2011 at 8:02 PM, Bryan Crossland <bacrossland@gmail.com> wrote:
On Wed, Apr 27, 2011 at 8:26 AM, Chief <chieff7@gmail.com> wrote:
What is the best and easiest way of running Ruby on Rails on a Windows
7 machine?

I really want to learn Rails, but I haven't found any easy way of
installing it on Windows 7.


Install a VM of Ubuntu or Linux and develop on that. Avoid installing Ruby or Ruby on Rails on Windows like the plague. You will be in for more trouble that it is worth trying to get everything you need to work on Windows.

B.

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

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

Ruby on Rails

There's a great article on AListApart about this, from a few years
back. Has a great Kevin Cornell illustration, too.

Basically, you want to make your page in (rendered) HTML precisely the
way non-scripted clients will see it. Then, when you load the page in
a scripted browser, you do all the following changes in the DOM to
support your effect. That way, you're using JavaScript to set up the
effect that only JavaScript can appreciate. It's a neat way to avoid
presenting a page that a person (or bot) cannot enjoy.

In a nutshell, you rewrite the DOM to wrap each empty input field with
a DIV position:relative, and move the label inside that DIV as a
position:absolute child with sufficient z-index to appear above the
input. Any non-empty fields get the same structural change, but their
labels are hidden at page load so they don't cover the filled input.
Next, you observe a click on the label to hide the label itself (and
the natural browser behavior will bubble through to focus the input).
Finally, you observe a blur on the input, and if the value is
different than the default (nothing) you restore the label. Otherwise,
it just remains hidden.

Walter

On Apr 29, 2011, at 1:42 PM, Fearless Fool wrote:

> [I originally posted this on the jquery forum, but I realize that I'll
> have to figure out the right syntax for form_for anyway, so it makes
> sense to cross-post here...]
>
> I'd like to be able to render forms, augmented by unobtrusive
> javascript
> that behave as follows:
>
> When javascript is enabled, the label appears inside the text field
> and
> vanishes on focus. The JQuery infield plugin by Doug Neiner
> (http://fuelyourcoding.com/scripts/infield/) is a good example of
> this.
>
> But when javascript is NOT enabled, the label appears on the outside,
> and not cleverly repositioned on the inside where it looks terrible.
> (Perhaps that's just a matter of different CSS styling?)
>
> Pointers welcome TIA.
>
> - ff
>
> --
> 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.

Ruby on Rails

On Apr 29, 2011, at 8:43 AM, Adel Mediouni wrote:

> hi,
> i would like to change a partial in my view with the change of the
> item in a select_tag:
>
> in the view:
>
> <%= observe_field("payment_id", :url => {:controller
> =>'user_admins' ,:action => 'rend_part'},:on => 'change', :frequency
> => 0.1) %>
> <%= select( "payment", "id", { "Visa" => "1", "Mastercard" => "2"}) %>
>
> in controller :
>
> def rend_part
>
> if params[:payment]['id'] == '1'
> render :partial => "patial_one"
> else
> render :partial => "patial_two"
>
> end
> end
>

And what happens when you do this? Does it work? Have you got a
function in place to update the page?

In long-hand Prototype.js code, this would look something like this:

$('my_picker').observe('change',function(evt){
new Ajax.Request('rend_part',{
parameters:{
payment_id:$F('my_picker')},
onSuccess:function(transport){
$('some_div').replace(transport.responseText);
}
}
});
});

How you go about doing this with the Ajax helpers is an exercise for
the student...

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

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

Ruby on Rails



On Sat, Apr 30, 2011 at 8:14 AM, Jeffrey L. Taylor <ror@abluz.dyndns.org> wrote:
How can download of files be tested?  The processing of the file is being
tested okay, but I don't know how to simulate the controller call.

What are you using to test? This is a bit off your topic as it sounds like you are writing controller specific tests. I used to do that, but in the last year I have started convering my ui and views heavily with testing and since doing this I find that I can achieve reasonably also testing the controller actions. I am sure some will argue against this but in the interest in time and quality I think I get more bang for my time covering how the user will use my ui. That said, I use rspec with capybara (steak) and using capybara, if there is a download link, I just click the link and then look at the page.body which gives me the content of the downloaded file.

I know you should be able to do so in a controller spec/test also, should be something like calling a get. I am not sure what your method is but if it has multiple formats then you would have to specify the format in a parameter I think, or do something like "get '/controller/action/file.pdf" or something like that. I would google for 'rails test file download', it looks like you will have some results you can at least piece together.
 

TIA,
 Jeffrey

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

Ruby on Rails



On Sat, Apr 30, 2011 at 7:36 AM, Ron Tsoref <chieff7@gmail.com> wrote:
First of all, thank you all for your suggestions.
I think I'll finally do the switch from Windows to Ubuntu. I wanted to do it for a while, and I think it's a good time to do it now.

Once I install Ubuntu, what should I do next?


Google for instructions on installing Ruby on Rails on Ubuntu, then if you run in to trouble post back here. But basically, you want to run the package installer (apt-get) to install ruby. Once ruby is installed you will be able to use ruby gems to install the rest you need. It is probably too much for right now but at some point you shold look at using rvm which helps you manage different versions of ruby on the same machine and to allow different installations of rails configurations for your different projects.
 

On Thu, Apr 28, 2011 at 8:02 PM, Bryan Crossland <bacrossland@gmail.com> wrote:
On Wed, Apr 27, 2011 at 8:26 AM, Chief <chieff7@gmail.com> wrote:
What is the best and easiest way of running Ruby on Rails on a Windows
7 machine?

I really want to learn Rails, but I haven't found any easy way of
installing it on Windows 7.


Install a VM of Ubuntu or Linux and develop on that. Avoid installing Ruby or Ruby on Rails on Windows like the plague. You will be in for more trouble that it is worth trying to get everything you need to work on Windows.

B.

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

Ruby on Rails

So I wanted to cook up a quick integration test for something, and I'm
using rspec. I personally just don't like Cucumber - just a personal
preference, not a slam to the test framework at all - and wanted to
stick to just pure rspec. So I dumped a quick spec file in spec/
reqests and ran it, and of course everything works.

But is this considered bad form, or a less-than-good practice? I've
never written a "request spec" before, so I'm probably mis-using it,
but I'd sure like to hear of better ways to do an integration test
under rspec where I can just run something like 'rake
spec:integration' (which doesn't exist by default). This was the best
I could do in a pinch, but wouldn't mind hearing some feedback on a
better way to do it in the future - WITHOUT cucumber, selenium,
webrat, capbybara, etc. etc. ;-)

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

Ruby on Rails

Others have mentioned railsinstaller, which I highly recommend if
you're just getting started. However, in my *personal* opinion, if
you're going to get serious about Rails development, you really need
some form of a *nix machine. The reason is that historically
speaking, Rubyists have been somewhat...reluctant to fully test and
support various ruby libraries on Windows. The architectures are just
so different and all. That doesn't mean Ruby CAN'T work on Windows,
just that you may wind up running into more weird "one-off" bugs than
it's worth.

You can download Ubuntu 10.10 (I agree with Colin's post about 11.04
having a few potential issues since it's so new) and VMWare Player
absolutely free. Use VMWare player (or there's also Oracle Virtual
Box as well, either one works) to set up a new Ubuntu Linux (or
there's Fedora, Gentoo, ArchLinux, etc. etc.) under Windows 7, then
launch that, and do your ruby development in there.

This is the approach I'm starting to use more and more these days
myself. If you have a mac, or have some hackintosh compatible
hardware, you can install OS X or the hackintosh version (look for
torrents and get it that way). Nobody's taking responsibility for
laws broken or stuff that breaks, etc. etc. blah blah blah (damn over-
lawyering).

Good luck man. If you're just getting your feet wet to see what it's
like, I recommend the Rails Installer route already linked. If you're
looking to get serious, go with a VM.

On Apr 27, 7:26 am, Chief <chie...@gmail.com> wrote:
> What is the best and easiest way of running Ruby on Rails on a Windows
> 7 machine?
>
> I really want to learn Rails, but I haven't found any easy way of
> installing it on Windows 7.

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

Ruby on Rails

How can download of files be tested? The processing of the file is being
tested okay, but I don't know how to simulate the controller call.

TIA,
Jeffrey

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

Ruby on Rails

On 30 April 2011 13:36, Ron Tsoref <chieff7@gmail.com> wrote:
> First of all, thank you all for your suggestions.
> I think I'll finally do the switch from Windows to Ubuntu. I wanted to do it
> for a while, and I think it's a good time to do it now.

A cautionary note, a new version of Ubuntu (11.04) has just been
released, which has made major changes to the UI and still has some
teething issues. I would advise an Ubuntu newcomer to install 10.10
for the moment (or even 10.04, the so called Long Term Support
release).

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.

Ruby on Rails

First of all, thank you all for your suggestions.
I think I'll finally do the switch from Windows to Ubuntu. I wanted to do it for a while, and I think it's a good time to do it now.

Once I install Ubuntu, what should I do next?

On Thu, Apr 28, 2011 at 8:02 PM, Bryan Crossland <bacrossland@gmail.com> wrote:
On Wed, Apr 27, 2011 at 8:26 AM, Chief <chieff7@gmail.com> wrote:
What is the best and easiest way of running Ruby on Rails on a Windows
7 machine?

I really want to learn Rails, but I haven't found any easy way of
installing it on Windows 7.


Install a VM of Ubuntu or Linux and develop on that. Avoid installing Ruby or Ruby on Rails on Windows like the plague. You will be in for more trouble that it is worth trying to get everything you need to work on Windows.

B.

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

Ruby on Rails



On 30 Apr 2011, at 12:48, Ernesto Rocha <ernestorrocha@gmail.com> wrote:

I did some brute force only to test, like this:

<meta name="csrf-param" content="authenticity_token"/>
<meta name="csrf-token" content="<%= CGI.escape form_authenticity_token %>"/>

some characters are escaped, but now the link_to ... :method => delete is not working anymore (the user session is killed).

If I user URI.escape the plus sign is not escaped.


How are you adding the authenticity token to the URL ?  (Ps, rails has a csrf_meta_tag helper)

Fred
So, i'm still at point zero.

Thanks,
Ernesto


On Fri, Apr 29, 2011 at 6:10 AM, Frederick Cheung <frederick.cheung@gmail.com> wrote:


On Apr 29, 3:06 am, Ernesto Rocha <ernestorro...@gmail.com> wrote:
> How i escape it before the rails server process it ?
>
You'll need to do that at the point that you add the token to the link

Fred
> Thanks,
> Ernesto
>
> On Thu, Apr 28, 2011 at 4:58 AM, Frederick Cheung <
>
>
>
> frederick.che...@gmail.com> wrote:
>
> > On 28 Apr 2011, at 03:22, Ernesto Rocha <ernestorro...@gmail.com> wrote:
>
> > Guys,
>
> > I'm using some AJAX on my application, but when protect_from_forgery is on
> > sometimes it works and sometimes the user session is killed. Today i found
> > out why.
>
> > It happens the following:
>
> > The authenticity_token is sent correctly as you can see below,
>
> > Started DELETE
> > "/clients/118/files/20?authenticity_token=hoMH9/heaFWXWWy+aE1xKQcpf4xrLoVWG qkq0pzzwuo="
> > for 127.0.0.1 at Wed Apr 27 23:06:50 -0300 2011
>
> > but, next line on server is,
>
> > Processing by ClippingsController#destroy as JS
> >   Parameters: {"authenticity_token"=>"hoMH9/heaFWXWWy
> > aE1xKQcpf4xrLoVWGqkq0pzzwuo=", "id"=>"20,", "client_id"=>"118"}
>
> > as you can see, the plus sign ('+') turned into a white space. Once the
> > token doesn't match the user session is killed.
>
> > Is someone experiencing this ? Any help how to fix it ?
>
> > + in urls means space - if the token genuinely contains + then you need to
> > escape it before putting it in the URL.
>
> > Fred
>
> > Thanks,
> > Ernesto
>
> > --
> > 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.


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