This tutorial was very helpful for me! Few weeks ago I've been working on activity feed myself. Any ideas how to aggregate activities to look something like 'Mike followed Ryan and 6 other developers'? Also my trackable object are polymorphic as well. Comment belongs to commentable models, Follow belongs to followable models. So it would be great to show follows and comments based on their polymorphic parent models. Is there any good solution? Thanks!
Dart is a FAIL. The last thing we need to see is a revival of client side browser programming fragmentation ala the VBScript days. JavaScript isn't going anywhere for the foreseeable future.
If you're going to keep previewing JavaScript frameworks can you please build a new app rather than do Raffler all over again. I get that it allows us to compare, but it also gets really samey-samey after a watching it being built 3,4,5 times.
I know this question is really old, but I was having the same problem and realized that my rake file was saved with a .rb extension instead of .rake. Just in case anyone else has this problem in the future, this could be something to double check.
Has anyone tried creating the nested forms but allowing only a certain limit of answers or number of questions? Ideally, I would like the jQuery to disable the add link for new question or answer if the number of questions has reached the maximum for that user.
RABL gets pretty cryptic as soon as you start returning complex JSON which is why I moved to jbuilder and while it served me well so far, AMS seems to offer a better structure and I plan to use it for my next project.
Please could you give an example of an activeresource model, which calls a protected RESTapi? With curl all is fine, but how can I deliver the token with a activeresource model?
Could someone elaborate on 'view_context' for me and why it doesn't need to hit the db to lookup the current user? Is this ActionView's context? Does it then have to run through the whole ActionView layer? I feel that this could be made more explicit or simplified.
Rails 4.0.0.beta1 seems to have dropped the 'new -b' option for using app builders. Does anyone know if this will be the case in production, or is it just a case of 'work in progress' ?
After doing everything that is said in this tutorial, and after running the rake db:migrate command, I get an error that says: NoMethodError in Active_admin/devise/sessions#new Showing /var/lib/gems/1.9.1/gems/activeadmin0.5.1/app/views/active_admin**/devise/sessions/new.html.erb where line #7 raised:
This is awesome! I've been using an early version of RABL in the past, and it seemed a bit hackish. I did not like the RABL syntax, and there were quite a lot of corner cases where it would not work as expected.
active_model_serializers looks much more stream-lined
In case anyone is interested, this is a really good talk done by Yehuda Katz (one of the authors of this gem) discussing rails APIs in general and active_model_serializers specifically. He makes a lot of good arguments toward this approach, one being convention over configuration.
I just ran through this tutorial two days ago and had it working. But tonight my app started throwing off that same error, which leads me to believe you are correct that it is on the Stripe side. Please let me know if they get back to you on that support ticket.
Your spec/requests folder should be spec/features to get capybara to work. This is if you are getting a NoMethodError: / undefined method `visit' error.
This article surprised me with a new use model. I see the value in the various methods for providing json for views, but I am building sparse yet complex data structures from the database to perform a diff, i.e. what changed between before and after a process ran.
Serializers seem like an ideal way to produce these structures, especially when it comes to writing exhaustive tests.
I was watching all the gotchyas of setting up a controller and action and objects and applying properties and outputting things into the view and going, "Whoa! Why!? Just use AngularJS." haha
I'm not sure what the advantage of Ember.js is yet—I'm sure there is one—maybe it just feels more comfortable to die-hard Rails fans.
My first comment seemed a little harsh after I read it. RABL is open source, and I am so grateful for people who take time out of there lives to contribute to open software.
What the comment should have said is.
"If you have performance concerns, or concerns of any type, it is always a good idea to take a peak at the issues page and make an informed decision."
Also, please note, I have never done any API versioning with ActiveModel::Serializers, never even looked up how to do it. And I can imagine that this is trickier than a view based approach.
However, I would also say, API versions don't (shouldn't) change very often, and performance is always a concern. You should do some research, benchmark all three json serializers, and see which one is best for you. Your experiences may be different than mine.
This sounds like a noob question, but I'm starting to learn Ruby. So I'm curious how this application is handling multiple user logging in/out. I figure that this revolves around using :user_id, but I'm confused regarding how :user_id is mapped to different user sessions (in particular :user_id is not defined anywhere before using, adding to my confusion). Hope someone can help to clear this up!
Did I miss something or is there a reason why you can't simply use the model's user for the owner?
In the comment model isn't the comment.user association the owner? Does the gem allow you to simply say
or the like? Seems like accessing the controller is over-kill in most cases.
Great 'cast. . . I am attempting to use the same technique to import XML.
Does anyone have pointers on how to work with XML using this approach?
Thanks in advance.
If you need to add nested-forms dynamically. You can have a look at
http://stackoverflow.com/questions/15072932/dynamically-adding-fixed-number-of-prepopulated-nested-forms-using-cocoon-and-ra/15275314#15275314
Thank you man - you saved me another day of searching :)
+1
So true +1
It's sometimes so boring to see the same functions all over.
This tutorial was very helpful for me! Few weeks ago I've been working on activity feed myself. Any ideas how to aggregate activities to look something like 'Mike followed Ryan and 6 other developers'? Also my trackable object are polymorphic as well. Comment belongs to commentable models, Follow belongs to followable models. So it would be great to show follows and comments based on their polymorphic parent models. Is there any good solution? Thanks!
Please fix the code markup, I see bunch of 'quot;'
When running the example code, I got the error:
I have already added the aws_access_key and aws_secret_key and bucket as well. Please help me with this issue, I don't know where is the problem.
Does someone know how to implement the same function of this railscast instead of jQuery tokeninput with select2?
I assume it is up to you and what status you get from your JSON call
Dart is a FAIL. The last thing we need to see is a revival of client side browser programming fragmentation ala the VBScript days. JavaScript isn't going anywhere for the foreseeable future.
Denis, i am trying to use datatables with i18n, but no successful. Could you give some hints to works with i18n? Please. Thanks.
When server side validation fails how does ember handle it?
If you're going to keep previewing JavaScript frameworks can you please build a new app rather than do Raffler all over again. I get that it allows us to compare, but it also gets really samey-samey after a watching it being built 3,4,5 times.
+1.2
I'm really curious to see Ryan's take on http://batmanjs.org/ (please do cover it)
I am getting a 404 not found on callback.
Heroku Logs
AbstractController::ActionNotFound (The action 'twitter' could not be found for Devise::OmniauthCallbacksController):
Nice episode!
I probably wouldn't have made the separate view for the submit form. Consider the alternative:
This way, both clicking the submit button and pressing enter within the text field will fire the
addEntry
action which gets handled by the controller.I know this question is really old, but I was having the same problem and realized that my rake file was saved with a
.rb
extension instead of.rake
. Just in case anyone else has this problem in the future, this could be something to double check.Did you find a solution to this?.. I am getting a similar error!
Thank you very much Esteban. It was just what I was looking for.
Congrats. 400 Episodes and still great.
Is anyone else getting these warnings from their assets on Trinidad? Know any workarounds?
rack-1.4.5/lib/rack/utils.rb:399 warning: multiple values for a block parameter (2 for 1
They originate from jruby-rack and it's been fixed on master but it looks like trinidad depends on an earlier version.
Has anyone tried creating the nested forms but allowing only a certain limit of answers or number of questions? Ideally, I would like the jQuery to disable the add link for new question or answer if the number of questions has reached the maximum for that user.
RABL gets pretty cryptic as soon as you start returning complex JSON which is why I moved to jbuilder and while it served me well so far, AMS seems to offer a better structure and I plan to use it for my next project.
Please could you give an example of an activeresource model, which calls a protected RESTapi? With curl all is fine, but how can I deliver the token with a activeresource model?
Thanks Ryan.
Could someone elaborate on 'view_context' for me and why it doesn't need to hit the db to lookup the current user? Is this ActionView's context? Does it then have to run through the whole ActionView layer? I feel that this could be made more explicit or simplified.
Thanks.
ActiveAdmin.register User do
form do |f|
f.inputs :email, :password, :password_confirmation
f.buttons :commit
end
end
It worked after I added this in the active admin's resource file -
/app/admin/users.rb
Rails 4.0.0.beta1 seems to have dropped the 'new -b' option for using app builders. Does anyone know if this will be the case in production, or is it just a case of 'work in progress' ?
Anyone have an example of how would you write a spec or test something like this?
I got inspired by your screencast, and wrote a comprehensive guide to Chef Solo and Vagrant: https://deveo.com/blog/2013/03/11/underneath-your-ruby-app-deployment-strategies-extracted/
Thanks!
After doing everything that is said in this tutorial, and after running the rake db:migrate command, I get an error that says:
NoMethodError in Active_admin/devise/sessions#new
Showing
/var/lib/gems/1.9.1/gems/activeadmin0.5.1/app/views/active_admin**/devise/sessions/new.html.erb where line #7 raised:
undefined method `username' for #AdminUser:0xa2ccb6c
I am new to rails, and not sure how to solve this. Any help is appreciated.
Thanks
holy crap, that's a awesome tutorial! Just what I was looking for, thanks!
hmmm, interesting.
Love this! Thanks Ryan!!
This is awesome! I've been using an early version of RABL in the past, and it seemed a bit hackish. I did not like the RABL syntax, and there were quite a lot of corner cases where it would not work as expected.
active_model_serializers looks much more stream-lined
thank you, Ryan!
In case anyone is interested, this is a really good talk done by Yehuda Katz (one of the authors of this gem) discussing rails APIs in general and active_model_serializers specifically. He makes a lot of good arguments toward this approach, one being convention over configuration.
http://www.youtube.com/watch?v=UlMpIHH1K5s
I just ran through this tutorial two days ago and had it working. But tonight my app started throwing off that same error, which leads me to believe you are correct that it is on the Stripe side. Please let me know if they get back to you on that support ticket.
Your spec/requests folder should be spec/features to get capybara to work. This is if you are getting a NoMethodError: / undefined method `visit' error.
Thanks for the tbody on the sortable call, was having an issue where it would drag the entire table!
This article surprised me with a new use model. I see the value in the various methods for providing json for views, but I am building sparse yet complex data structures from the database to perform a diff, i.e. what changed between before and after a process ran.
Serializers seem like an ideal way to produce these structures, especially when it comes to writing exhaustive tests.
Thanks for a completely new idea, Ryan!
Hey I'm trying to get rid of striping in my table, and I'm not exactly sure how to do that? Any help would be appreciated!!
+1 for sure!
I was watching all the gotchyas of setting up a controller and action and objects and applying properties and outputting things into the view and going, "Whoa! Why!? Just use AngularJS." haha
I'm not sure what the advantage of Ember.js is yet—I'm sure there is one—maybe it just feels more comfortable to die-hard Rails fans.
If you use this with more than 1 model here is an example of how you could refactor your PermittedParams class to allow more flexibility:
I don't understand this line in the allow? method.
Could someone break it down for me please?
Why not just use a Draper decorator with an "#as_json" method?
I think it is much simpler than having separate serializers and decorators.
My first comment seemed a little harsh after I read it. RABL is open source, and I am so grateful for people who take time out of there lives to contribute to open software.
What the comment should have said is.
"If you have performance concerns, or concerns of any type, it is always a good idea to take a peak at the issues page and make an informed decision."
Also, please note, I have never done any API versioning with ActiveModel::Serializers, never even looked up how to do it. And I can imagine that this is trickier than a view based approach.
However, I would also say, API versions don't (shouldn't) change very often, and performance is always a concern. You should do some research, benchmark all three json serializers, and see which one is best for you. Your experiences may be different than mine.
At this moment (and this will change), look at the first five issues for RABL, four of them dealing with Caching.
https://github.com/nesquena/rabl/issues
Hi,
This sounds like a noob question, but I'm starting to learn Ruby. So I'm curious how this application is handling multiple user logging in/out. I figure that this revolves around using :user_id, but I'm confused regarding how :user_id is mapped to different user sessions (in particular :user_id is not defined anywhere before using, adding to my confusion). Hope someone can help to clear this up!
Thanks!