Ruby on Rails Tuesday, April 29, 2014



On Monday, April 28, 2014 8:32:17 PM UTC-4, Ruby-Forum.com User wrote:
Thank you very much, It looks like you're right. All these problems
began to occur after I moved the app to production using
passenger/nginx. I used google version because that was the last
version. I did not know this was being included twice by jquery_ujs.js.
In fact, I was able get rid of some of the error by doing some changes
after your suggestion.

To tell you the truth, the problem is not so much programming but
understanding the concepts of about rails architecture and its modules.
This for me is the hard part. I am still at the beginning of the curve,
but I hope with your suggestion and I will get there.

One more thing:

Do you recommend to testing locally with nginx my rails app? I believe
it will bring the closest scenario to the one I am using i production,
specially if I can debug to better understand the errors.

Rod

mike2r wrote in post #1144331:
> On Sunday, April 27, 2014 5:12:41 PM UTC-4, Ruby-Forum.com User wrote:
>>   def index
>>
>>     end
>>       end
>> >> event.preventDefault() instead. jquery.js:75
>> >> <html>
>> >> --
>> > I may have a better idea of exactly what's happening when I see the
>> Posted via http://www.ruby-forum.com/.
>>
>
> The statement causing the problem is:
>
> layout 'home'
>
> Rails uses layouts and templates in its view rendering system (plus
> other
> things, but let's start with that).  The default layout is
> application.html.erb.  With the above statement, you've overridden the
> default.  I'm assuming that you were having issues because the default
> template for this action would be index.html.erb and you wanted it to be
> home.html.erb.  You would accomplish that by 1) get rid of the layout
> statement and 2) insert the following statement at the end of the index
> action:
>
>  render template: 'home'
>
> You will have some other issues when you do this.  The layout is
> intended
> to be the overall framework and, at a minimum, includes the following:
> <!DOCTYPE html>
> <html>
> .
> .
> </html>
>
> The contents of the template (home.html.erb) will be inserted where you
> see
> the word yield in the application layout.  In your case, you've defined
> the
> doctype and html tag in both the application layout and the template
> which
> will result in the html tag being defined twice which is invalid html.
>  Again, I refer you to the guide linked above.
>
> You're going to have a few other issues.  You are separately loading the
> jquery and jquery-ui files from google.  Once you have this working
> correctly, that will result in those files being loaded twice and
> potentially two different versions:  the rails version and the version
> you're loading from google.
>
> I also encourage you to go through a good tutorial such as
> railstutorial.org.  You seem to have a pretty good foundation in ruby,
> so I
> don't think it would take you long to go through the tutorial.  You are
> doing a lot of things in your controller that 1) you don't need to do if
> you work with Rails conventions and 2) some of them belong in a model.

--
Posted via http://www.ruby-forum.com/.

There's generally three levels of testing in Rails:

1) Unit testing:  this is part of the Rails architecture and doesn't depend on a browser.  I use rspec/capybara, others use the standard test unit supplied with Rails, etc.  This is basically automated testing and does a very good job of testing controllers/models to insure the right things are happening with respect to information produced (or not produced), retrieved and saved correctly, etc.  

2) Visual testing which is testing in the browser.  When you're writing views, for example, it's pretty much necessary to see things in a browser.  In this case, I always test in development mode because changes you make are automatically reflected on a refresh.  This is accomplished by having sprockets and the pipeline live.  In production, everything has to be pre-compiled and that would significantly slow development time.

3) Once you have developed the piece or application that you are now ready to show the client/user, you should test it in the nginx/passenger production environment (or whatever environment the application will be running in in production).  As you have seen above, things can happen and you should always test this before releasing a piece of your work to be reviewed.

I should note you can use nginx/passenger and run it in the development environment.  I sometimes do this, sometimes I just use WEBrick (rails server).  

This is just my opinion, there a lot of different ways to do this but however you do it, and whatever tools best fit you, it is important that you test.

The railstutorial.org I referred to in the above posts is free and the tutorial largely focuses on the rails architecture and models.  It takes you through the construction of a basic twitter-like site step by step, explaining the concepts as you go.  I think there's one chapter on basic ruby you could probably skip.  

mike

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/50290595-6e3c-43e0-b4bf-e74e65aea369%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment