Here's hoping someone can help. After setting up my linode acct & deploying, a couple links did not work (production only). So I made a few changes, thinking it was a cancan incompatibility with to_params, and now none of the link_to's work. In the production log it looks like it's trying to serve up a request to another host:
Started POST "/slingads/index.php" for 203.142.100.15 at 2013-02-08 16:50:22 -05
00
Error…500 error.
ActionController::RoutingError (No route matches [POST] "/slingads/index.php"):
actionpack (3.2.11)
Do I have a security breach & how should I handle this? Would it be best to just dump the database and start over? Any advice is much appreciated.
Thanks,
Cathy
PS) That ip address is for a company in HongKong!
Is it certain that "CONFIG.merge! CONFIG.fetch(Rails.env, {})" will pull in heroku environment variables pulled in via heroku config:push from the .env file?
Sure. There are a few ways to debug your code. With imperative business logic (usually contained inside services), you can still use debugger and step through the code. DOM manipulation and scope binding are done through things called directives (ng-click etc. are all directives), so you can put a debugger in your directives' code and step through it as well.
For view related debugging, you can get access to scopes (which Angular stores on DOM elements) via angular.element([DOM Element]).scope(); there is also a good Chrome extenion called AngularJS Batarang that can help you see the scopes attached to the DOM, and also help you do profiling regarding slow $watches ($watch is the mechanism through which Angular does dirty tracking and automatic view updating).
I'm the new maintainer of metric_fu and it should work now on ruby 1.9 without any problems. See configuration instructions at https://github.com/metricfu/metric_fu which include how you can have metric_fu load external coverage output (e.g. using simplecov)
Rcov on ruby 1.9 segfaults and fails a lot, so running it is disabled by default and the gem is no longer included as a dependency. However, you may still config it to run or load coverage stats you've already generated
Also, it works from the command-line now. Now need to bundle it or run rake or metrical
Thanks Brandon. This is an excellent explanation. Could you provide more details on how to "debug" an application that is using Angular.js? In the Backbone app., I just put a debugger statement where I need to and examine the code variables etc. in the debugger.
For me, AngularJS is perfect, everything just works with few code (I tried backbone, ember, pure jquery... and I didnt like anyone for this case).
I have a social network too, but I use angularJS just to chat... everything else is rails with pjax that I think is a better solution to this kind of webapp.
I use memcache (A LOT), my social network is below to 100ms per request, with more than 1,000 online users.
My chat uses nodejs on server, and it support xmpp/jabber as well. It is 50% socket.io and 50% node-xmpp.
In this object which is a view, you are setting up event handlers on various elements. These event handlers call functions on the view object, which delegate to models. You also set up callbacks on various model events (such as change) which in turn call functions on the view object to update the view accordingly.
In Angular, the DOM is your view. When using ng-click, ng-submit, etc., you are setting up event handlers on these elements, which call functions that should delegate to model objects. When using ng-show, ng-repeat, etc. you are setting up callbacks on model events that change the view.
The fact that AngularJS sets up these callbacks behind the scenes for you is irrelevant; the only difference between this and something like Backbone is that Angular lets you write your view declaratively--you describe what your view is--rather than imperatively--describing what your view does.
So, in in the end, <a ng-click="model.set({selected: true})"> really adds no more dependencies than
If anyone else finds this useful, I wanted to do all I could to avoid using a POST for my various search forms, so I created a gem that allows abbreviations of column and association names in the Ransack queries: Ransack Abbreviator
Any advice on generating a dynamic clause... for example, "saved search" where a user could select which column, operator, value which could be multiple as well... for example:
column, operator, value, next_operator
make == ford |
make == pontiac &
year == 1993..1998
Yeah, this can be a problem, and people have come up with some pretty clever ways to combat the issue. In our case, the content we display lends itself well to rendering some very basic data on the server into noscript tags, and we are going to experiment with that idea first.
I think that you are getting stuck on the "literal" interpretation of a "single page" app. Instead think about the Rich client apps that we have been developing for the past 20 years using clients such as VB PowerBuilder etc. for client/server applications. A single page app is more akin to these Rich Client interfaces of the past years. It does not mean that "multiple" single page app(lets) cannot be bound together to create one "holistic" application. In fact, they have already implemented the Twitter Bootstrap UI widgets in Angular so it is a matter of stitching together many single page angular app(lets) using the UI elements such as tabs, forms, pop-ups, etc.
"wrt ng-click=”archive()” which is mixing html with app logic - where is the logic? it's archive is just a hook to the controller which defines the logic.
For years we've been told about unobtrusive JavaScript and what we ended up with was spaghetti code with unclear relationships between the template and event handlers.
I'm absolutely against logic in the templates, but we have to distinguish between the actual code that represents the business logic and a hook that calls a routine with the business logic."
I've released angularjs_scaffold to help you develop your app with angularjs and rails (it generates angular's models, controllers and views) https://github.com/patcito/angularjs_scaffold
I am using pjax also with my rails application ,I am doing simple social network ,can u provide my with ur code or hints how can I implement chat app on my site ,,I am an expert rails developer and intermediate javascript ,,your help is really valuable for me
The migration to setup hstore only runs if the account your Rails app is using to access Postgres has superuser access. If you want to grant this temporarily, you can do this at postgres prompt (assuming your own postgres login is a superuser account):
alter user [rails account name] with superuser;
then revoke when done... alter user [rails account name] with nosuperuser;
Does anybody know what implications there are as the keys change within an hstore column over time? Are migrations needed to make the keys consistent in the hstore column?
For example:
initial model class created with hstore column with keys:
:foo :bar
data added to database
one row/record has "foo"=>"blah", "bar"=>"blah blah"
...
later changes made to model class new key added to hstore column
:baz
more data added to database
...
second row/record has "foo"=>"blah", "bar"=>"blah blah", "baz"=>"blah blah blah"
Do I have to go back and make sure that the first record has an empty :baz property?
What about the removal of keys? What happens if I remove :foo from my model?
AstonJ, as a rails beginner, I've found Master Space and Time with Javascript by Noel Rappin to be an excellent resource on Javascript -- specifically if you're accustomed to rails development.
I'm still on the first book, but looking forward to the next three!
Here is my small opensource project written in angularjs https://github.com/lucassus/mongo_browser I think it could be a good starting point for anyone interested in combining ruby apps with this awesome js framework ;)
Would have been nice to mention that HSTORE columns only take simple text strings but no slightly more complex JSON data (e.g. Array of Hashes). Might have been obvious to some, but I stumbled right passed it.
I would REALLY like how integration with a testing framework. In particular, how to test interaction with the server, e.g. interaction requires login, and test verifies response from server.
Hey Ryan,
You should continue with Angular JS screencasts to build a non-trivial application and then repeat the process with Ember JS. That will give us a good frame of reference. Your Backbone screencasts have been very useful to me in coming up to speed.
Just a suggestion.
Keep up the good work.
Hi Ryan et al.
Here's hoping someone can help. After setting up my linode acct & deploying, a couple links did not work (production only). So I made a few changes, thinking it was a cancan incompatibility with to_params, and now none of the link_to's work. In the production log it looks like it's trying to serve up a request to another host:
Started POST "/slingads/index.php" for 203.142.100.15 at 2013-02-08 16:50:22 -05
00
Error…500 error.
ActionController::RoutingError (No route matches [POST] "/slingads/index.php"):
actionpack (3.2.11)
Do I have a security breach & how should I handle this? Would it be best to just dump the database and start over? Any advice is much appreciated.
Thanks,
Cathy
PS) That ip address is for a company in HongKong!
Is it certain that "CONFIG.merge! CONFIG.fetch(Rails.env, {})" will pull in heroku environment variables pulled in via heroku config:push from the .env file?
Sure. There are a few ways to debug your code. With imperative business logic (usually contained inside services), you can still use
debugger
and step through the code. DOM manipulation and scope binding are done through things called directives (ng-click
etc. are all directives), so you can put a debugger in your directives' code and step through it as well.For view related debugging, you can get access to scopes (which Angular stores on DOM elements) via
angular.element([DOM Element]).scope()
; there is also a good Chrome extenion called AngularJS Batarang that can help you see the scopes attached to the DOM, and also help you do profiling regarding slow$watch
es ($watch
is the mechanism through which Angular does dirty tracking and automatic view updating).There is another one, JS MVC framework for Rails - Joosy. And Node.js is not a client side framework. It's the server side framework.
+1
I'm the new maintainer of metric_fu and it should work now on ruby 1.9 without any problems. See configuration instructions at https://github.com/metricfu/metric_fu which include how you can have metric_fu load external coverage output (e.g. using simplecov)
Rcov on ruby 1.9 segfaults and fails a lot, so running it is disabled by default and the gem is no longer included as a dependency. However, you may still config it to run or load coverage stats you've already generated
Also, it works from the command-line now. Now need to bundle it or run rake or metrical
Thanks Brandon. This is an excellent explanation. Could you provide more details on how to "debug" an application that is using Angular.js? In the Backbone app., I just put a debugger statement where I need to and examine the code variables etc. in the debugger.
Can you elaborate on that a bit?
Bharat
See TodoMVC to help you decide.
bundle update and changing jquery-rails to version 2.1.4 (JQuery 1.8.3) seemed to solve it over here too.
Thanks, man.
For me, AngularJS is perfect, everything just works with few code (I tried backbone, ember, pure jquery... and I didnt like anyone for this case).
I have a social network too, but I use angularJS just to chat... everything else is rails with pjax that I think is a better solution to this kind of webapp.
I use memcache (A LOT), my social network is below to 100ms per request, with more than 1,000 online users.
My chat uses nodejs on server, and it support xmpp/jabber as well. It is 50% socket.io and 50% node-xmpp.
Maybe, I'll opening it source. I dont know yet.
if you want, add me on gtalk: maxguzenski@gmail.com
Migrating from Ember.js to AngularJS ;)
Thank you Ryan. This is really amazing screencast.
I have been seeing the lots of JavaScript frameworks on the planet. How can we determine the correct JavaScript framework?
[Angular|Knockout|Backbone|Active|Sammy|Raphael|Node].JS
Which is the best solution for specific applications as i expected to use with Rails?
I assume that Angular is a good starting point. :)
:)
I very much agree with Patrick's comment, but here's another way to think about it:
In a framework like Backbone, you'd have something like the following code (taken from the Backbone website, minus a few lines):
In this object which is a view, you are setting up event handlers on various elements. These event handlers call functions on the view object, which delegate to models. You also set up callbacks on various model events (such as
change
) which in turn call functions on the view object to update the view accordingly.In Angular, the DOM is your view. When using
ng-click
,ng-submit
, etc., you are setting up event handlers on these elements, which call functions that should delegate to model objects. When usingng-show
,ng-repeat
, etc. you are setting up callbacks on model events that change the view.The fact that AngularJS sets up these callbacks behind the scenes for you is irrelevant; the only difference between this and something like Backbone is that Angular lets you write your view declaratively--you describe what your view is--rather than imperatively--describing what your view does.
So, in in the end,
<a ng-click="model.set({selected: true})">
really adds no more dependencies than...but it sure is a hell of a lot less code. ;)
I've got the same issue.
If anyone else finds this useful, I wanted to do all I could to avoid using a POST for my various search forms, so I created a gem that allows abbreviations of column and association names in the Ransack queries: Ransack Abbreviator
How can I integrate Unfuddle API ??? Will you please give some idea.
+1
Does anyone know if it works with apache and passenger? I've been using it for a while.
+1
There's http://drone.bz and Rails Composer as well, which are nice to use.
Any advice on generating a dynamic clause... for example, "saved search" where a user could select which column, operator, value which could be multiple as well... for example:
column, operator, value, next_operator
make == ford |
make == pontiac &
year == 1993..1998
Yeah, this can be a problem, and people have come up with some pretty clever ways to combat the issue. In our case, the content we display lends itself well to rendering some very basic data on the server into
noscript
tags, and we are going to experiment with that idea first.I think that you are getting stuck on the "literal" interpretation of a "single page" app. Instead think about the Rich client apps that we have been developing for the past 20 years using clients such as VB PowerBuilder etc. for client/server applications. A single page app is more akin to these Rich Client interfaces of the past years. It does not mean that "multiple" single page app(lets) cannot be bound together to create one "holistic" application. In fact, they have already implemented the Twitter Bootstrap UI widgets in Angular so it is a matter of stitching together many single page angular app(lets) using the UI elements such as tabs, forms, pop-ups, etc.
The AngularJS guys already answered that one: http://blog.ricodigo.com/blog/2012/10/14/announcing-the-release-of-angularjs-scaffold/#comment-686036118
Copy/pasta:
"wrt
ng-click=”archive()” which is mixing html with app logic
- where is the logic? it's archive is just a hook to the controller which defines the logic.For years we've been told about unobtrusive JavaScript and what we ended up with was spaghetti code with unclear relationships between the template and event handlers.
I'm absolutely against logic in the templates, but we have to distinguish between the actual code that represents the business logic and a hook that calls a routine with the business logic."
I've released angularjs_scaffold to help you develop your app with angularjs and rails (it generates angular's models, controllers and views) https://github.com/patcito/angularjs_scaffold
and in your opinion ,,which framework is the best for rails application , Ember ,angular ,backbone ,for chat application for example
I am using pjax also with my rails application ,I am doing simple social network ,can u provide my with ur code or hints how can I implement chat app on my site ,,I am an expert rails developer and intermediate javascript ,,your help is really valuable for me
To be more clear, what happens when you have a database that looks like this after several changes to the model:
The migration to setup hstore only runs if the account your Rails app is using to access Postgres has superuser access. If you want to grant this temporarily, you can do this at postgres prompt (assuming your own postgres login is a superuser account):
alter user [rails account name] with superuser;
then revoke when done...
alter user [rails account name] with nosuperuser;
Excellent cast, I can definitely see how the jQuery soup I currently have can be moved into AngularJS. And 404 not found - very funny.
http://stackoverflow.com/questions/9572834/starting-thin-server-without-the-thin-gem-does-not-work
gem 'thin'
Is necessary put into Gemfile. Lock this error at Stackoverflow
Link
Episode 404 is missing, great joke!
After logging into https://myapp.com using devise, it does not recognize https://www.myapp.com (it shows login page) . Any ideals?
Example of how to not populate the global name space using Angularjs and Coffeescript.
please mate how do i add a default image, maybe when new user logged in he can see it ?
Does anybody know what implications there are as the keys change within an hstore column over time? Are migrations needed to make the keys consistent in the hstore column?
For example:
initial model class created with hstore column with keys:
:foo :bar
data added to database
one row/record has
"foo"=>"blah", "bar"=>"blah blah"
...
later changes made to model class new key added to hstore column
:baz
more data added to database
...
second row/record has
"foo"=>"blah", "bar"=>"blah blah", "baz"=>"blah blah blah"
Do I have to go back and make sure that the first record has an empty :baz property?
What about the removal of keys? What happens if I remove :foo from my model?
Er, that should have been "I would REALLY like to see how integration with a testing framework can be done." :$
AstonJ, as a rails beginner, I've found Master Space and Time with Javascript by Noel Rappin to be an excellent resource on Javascript -- specifically if you're accustomed to rails development.
I'm still on the first book, but looking forward to the next three!
Thanks Brandon. I have actually done most of the Code School stuff :) Do you have any book recommendations?
please mate how do i add a default image, maybe when new user logged in he can see it ?
Here is my small opensource project written in angularjs https://github.com/lucassus/mongo_browser I think it could be a good starting point for anyone interested in combining ruby apps with this awesome js framework ;)
Would have been nice to mention that HSTORE columns only take simple text strings but no slightly more complex JSON data (e.g. Array of Hashes). Might have been obvious to some, but I stumbled right passed it.
Ryan, excellent as always!
I would REALLY like how integration with a testing framework. In particular, how to test interaction with the server, e.g. interaction requires login, and test verifies response from server.
Maybe Turbolinks is replacing your ng-app tag. If it is the case, you have to rebind angular with "angular.bootstrap(element[, modules]);"
Are you sure? I use pjax with Rails 3.1 and have a chat (like facebook) with angularJS... everthing just works.
You are so right! If you look at ATG Dynamo (acquired by Oracle), you will see a striking resemblance. It is a matter of personal preference really :)
Hey Ryan,
You should continue with Angular JS screencasts to build a non-trivial application and then repeat the process with Ember JS. That will give us a good frame of reference. Your Backbone screencasts have been very useful to me in coming up to speed.
Just a suggestion.
Keep up the good work.
i believe it's now SEOable with the use hashbang