how to use this functionality to import data for model associations
This is my case
class SampleRequest < ActiveRecord::Base
has_one :sample_request_text_excerpt
accepts_nested_attributes_for :sample_request_text_excerpt
end
class SampleRequestTextExcerpt < ActiveRecord::Base
belongs_to :sample_request
end
In the sample_request model, asset type field would be text and image , for text type different excel sheet and for image type different excel sheet , only certain field would be extra in the sample_request_text_excerpt model.
For single model no issues , while try to use for associations
this line showing error
sample_request.attributes = row.to_hash
while uploading the text spreadsheet error displayed
Yes I have done enough poking around on forums to understand that I have something running, its just that its a fresh rebuild... I didn't think anything would be running because of that.
That being said... How do I close this running thing?
Hello I learned a lot from this episode about Polymorphic association, which always seemed a bit mysterious!
I think what the episode is really missing, is an explanation about polymorphic_url or polymorphic_path in order to recognize which model you wish to redirect. It is extremely helpful to understand this method especially when nesting multiple polymorphic models (see documentation). For example
ruby
defupdate@comment = Comment.find(params[:id])
@comment.update_attributes(params[:comment])
response_to do |format|
format.html doif@comment.errors.present?
render :editelse
redirect_to polymorphic_path(@commentable), :notice => "Yay updated!"# or# redirect_to polymorphic_path([@commentable, @comment]), :notice => "Yay i can update and see further down the path!"endendendend
sorry if messed up the comment markup ^^
Thank you Ryan for the wonderful videos. I have been watching your masterpieces for a few years. I love your Pro and Revised versions, Keep it up!
Thanks for yet another great set of videos. Quick question however. Let's say your article would have a 1-n association with a tree-like structure called 'article_subjects', and that you would also want to be able to search based on these article_subjects (and their parents). Any idea on how we could achieve this?
Ok I understand. I'm not sure I'd want to back out of the transaction because the activity tracking failed though... the recipe saved, the notification failed - seems like a secondary transaction to me, failure of which would be logged, retried and possibly even pushed onto a queue or other out-of-band process.
It creates
- Twitter Bootstrap
- Sorcery :remember_me and :reset_password
- CanCan 2.0
- Simple_Form
Ran a few successful tests. Definitely cuts out the BS in the setting up of base app and gets into the fun part. Almost reminds me of the yii demo app or asp.net mvc template app.
Huge time saver and less running around to find the old scripts for the authentication reset password stuff!
I'm betting you're trying to deploy to an instance with 8GB of storage (like a T1.micro)? Try adding the following to config/rubber/role/mongodb/mongodb.conf:
I have had the same issue with equality. I ended up letting Struct solve the equality issues for me. This preserves equality for usage with arrays, hash (keys), sets etc..
The example below decorates ServiceType with start_date & end_date from another model:
I just found a issue in version 0.2.0 where it only permits attributes that belong to your model any additional fields are ignored. If any body else is facing this issue you can downgrade the gem by doing
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
Any suggestions would be greatly appreciated. Thanks.
@Er.Love the syntax is:
Model.where(name: /#{params[:q]}/)
I hope you found it since then ;)
I'm having an issue. the selected tokens are not sent when I validate my form. I all the other fields are send except those ones!
I'm running rails 3.2.9 with mongodb
Ryan, as always great video.
But, I am having trouble with credentials need to get in to a secure Soap api. Also, now there is a new version of Savon. I was wondering if you can do a revised tutorial which will include using an action that requires login, if possible.
I think this episode needs a part 2 or maybe part 3 episode since most rails apps are more complex. Would be great to have a proof of concept for a website with different pages, authentication, authorization.
I implemented an activity feed last year which was a bit more complex than this. It had to store data such as specific actions like updating a models state column (from/to), as well as displaying consecutive activity grouped by the person who did it, and grouping the same consecutive action by the same person as "XX updated XXX (4 times)". Would be nice to see another pro episode that handled this display related stuff, since my code is kind of messy, and it's be cool to see how it might be implemented by someone else.
I'm not sure what version of jquery-rails used to produce this error, but it looks like there's an issue with jquery-rails version 2.2.1 and jQuery File Upload 0.4.1. I downgraded to jquery-rails version 2.1.4 and that did the trick.
It looks like in current rails (3.2.12 and sometime since this episode), application.rb now combines the require frameworks into rails/all. This make commenting out require 'rails/test_unit/railtie' problematic. So it runs the tests in default directories (the first test run: partial based on rails defaults).
Per this episode we are loading all the *_test.rb files which allows for the custom directories (the second test run: full).
There is probably a way to do the equivalent of commenting out the rails/test_unit/railtie require without having to be responsible to maintain the other requires that rails/all buys us... however you can get around this for now by adding in minitest.rake:
Thomas, that fix worked great. Thanks!
Is this still up to date?
Solves the problem for me.
how to use this functionality to import data for model associations
This is my case
class SampleRequest < ActiveRecord::Base
has_one :sample_request_text_excerpt
accepts_nested_attributes_for :sample_request_text_excerpt
end
class SampleRequestTextExcerpt < ActiveRecord::Base
belongs_to :sample_request
end
In the sample_request model, asset type field would be text and image , for text type different excel sheet and for image type different excel sheet , only certain field would be extra in the sample_request_text_excerpt model.
For single model no issues , while try to use for associations
this line showing error
sample_request.attributes = row.to_hash
while uploading the text spreadsheet error displayed
Fantastic episode, has helped me a lot. Can I suggest a tweak to the remove_fields coffee script :
$(document).on 'click', 'form .remove_fields', (event) ->
$('input[name$="[_destroy]"]', $(this).siblings()).val('1')
$(this).closest('fieldset').hide()
event.preventDefault()
This makes it less dependent on the position of the hidden destroy field.
Installing Ruby on CentOS:
https://gist.github.com/denispeplin/5011950
Hi Ryan,
Can you please update the episode as it is for Ruby 1.9.2 and rails3.0.1.
It is throwing error for "ActionController::RoutingError (undefined method `referenced_in' for Article:Class" when using rails 3.2.9 and ruby 1.9.3
Thanks,
Vardhan.
Please refer to the new changes in sferik's gem: https://github.com/sferik/twitter#configuration
Yes I have done enough poking around on forums to understand that I have something running, its just that its a fresh rebuild... I didn't think anything would be running because of that.
That being said... How do I close this running thing?
Thanks,
Sam.
Hello I learned a lot from this episode about Polymorphic association, which always seemed a bit mysterious!
I think what the episode is really missing, is an explanation about polymorphic_url or polymorphic_path in order to recognize which model you wish to redirect. It is extremely helpful to understand this method especially when nesting multiple polymorphic models (see documentation). For example
sorry if messed up the comment markup ^^
Thank you Ryan for the wonderful videos. I have been watching your masterpieces for a few years. I love your Pro and Revised versions, Keep it up!
@Gerald: Thanks so much for this fix. This totally solved my problems :)
http://ericlondon.com/posts/246-importing-and-converting-csv-data-into-a-rails-model-with-a-slick-active-admin-interface
Hello!!!,
I'm not able to use autocomplete, I'm getting the following issue;
ReferenceError: Ajax is not defined
TKS :)
i have <%= button_to "游客入口", signup_path, :method=> :post %> and
def create
end
but when i click button it can't creat a new guest.it just link to signup_path.Doesn't the method post work?
How do you close it?
It means you have another web server in your vps, close it.
Thanks for yet another great set of videos. Quick question however. Let's say your article would have a 1-n association with a tree-like structure called 'article_subjects', and that you would also want to be able to search based on these article_subjects (and their parents). Any idea on how we could achieve this?
Could anyone let me know why I am receiving this error on postback?
Could not authenticate you from Twitter because "Invalid credentials".
Ryan, what do you think of audited gem - https://github.com/collectiveidea/audited. This seems to be another solution to provide similar functional.
Ok I understand. I'm not sure I'd want to back out of the transaction because the activity tracking failed though... the recipe saved, the notification failed - seems like a secondary transaction to me, failure of which would be logged, retried and possibly even pushed onto a queue or other out-of-band process.
I take back what I said. It is more of a time saver than I had originally thought. I've posted the below generator.
https://github.com/kobaltz/app_template_generator
It creates
- Twitter Bootstrap
- Sorcery :remember_me and :reset_password
- CanCan 2.0
- Simple_Form
Ran a few successful tests. Definitely cuts out the BS in the setting up of base app and gets into the fun part. Almost reminds me of the yii demo app or asp.net mvc template app.
Huge time saver and less running around to find the old scripts for the authentication reset password stuff!
I'm betting you're trying to deploy to an instance with 8GB of storage (like a T1.micro)? Try adding the following to config/rubber/role/mongodb/mongodb.conf:
Check out Ryan's nested form gem wiki.
https://github.com/ryanb/nested_form/wiki/Integrating-with-client_side_validations
Hope this could help you. I tested here and it was ok.
As always. I'm looking at angularJS because I have to rewrite something.
Let's check out Railscasts... BÄM.. Tutorial for exactly that.
Mindreader.
Cheers
Anyway to convert the sort_links into bootstrap buttons?
I managed to apply a form-inline class to the search_form_for thanks to Tom Harrisson, thanks!:
<%= search_form_for @search, :html => {:class => "form-inline"} do |f| %>
Any idea how to apply a css custom button to:
<%= sort_link @search, :title, "Title" %>
Thankyou
You should always do both. Never rely on client only :)
I have had the same issue with equality. I ended up letting Struct solve the equality issues for me. This preserves equality for usage with arrays, hash (keys), sets etc..
The example below decorates ServiceType with start_date & end_date from another model:
Hi Ryan (and all),
I'm getting times near to 10ms when retrieving search suggestions (using redis). BTW, my dev enviroment is a Mac Book Pro (8GB Ram, intel core I7)
Any clues on why I'm getting such bad response times? Based on the video I guess they should be better.
I just found a issue in version 0.2.0 where it only permits attributes that belong to your model any additional fields are ignored. If any body else is facing this issue you can downgrade the gem by doing
and then running bundle
Definitely a part 2 worth!!
Hey all very green here, first time using Linode
(early on in the tutorial)
When running:
root@li511-230:~# service nginx start
I get:
Any suggestions would be greatly appreciated. Thanks.
@Er.Love the syntax is:
Model.where(name: /#{params[:q]}/)
I hope you found it since then ;)
I'm having an issue. the selected tokens are not sent when I validate my form. I all the other fields are send except those ones!
I'm running rails 3.2.9 with mongodb
Just a small note in case others had the same issue i did:
This:
# specify what domain to use for mailer URLs
config.action_mailer.default_url_options - { host: "localhost:3000" }
Should actually be:
# specify what domain to use for mailer URLs
config.action_mailer.default_url_options = { host: "localhost:3000" }
Once i changed the - to an =, it worked fine. Thanks again for a great railscast and gem!
friend_id comes from the sample "Recipe Application" which has "friends".
this => https://github.com/smartinez87/exception_notification/issues/113
Ryan, as always great video.
But, I am having trouble with credentials need to get in to a secure Soap api. Also, now there is a new version of Savon. I was wondering if you can do a revised tutorial which will include using an action that requires login, if possible.
I'm having the same issue. Does someone knows the answer?
+1
I'd love to see a cast on Redis taking activity feeds to the next level Ryan :)
Hi!
Can you tell what performance issues you have?
Fantastic clip there, thanks for sharing.
Thx for this episode. Where is part 2? :)
I think this episode needs a part 2 or maybe part 3 episode since most rails apps are more complex. Would be great to have a proof of concept for a website with different pages, authentication, authorization.
Have a nice day.
ruby-1.9.3-p362 is buggy, and it's a known issue. so reinstall newer stable version(like 1.9.3-p374)
ruby-1.9.3-p362 is buggy, and it's a known issue. so reinstall newer stable version(like 1.9.3-p374)
wow, looks good!
I'm using DataTables, but will be switching!
I like the walkthroughs.
I implemented an activity feed last year which was a bit more complex than this. It had to store data such as specific actions like updating a models state column (from/to), as well as displaying consecutive activity grouped by the person who did it, and grouping the same consecutive action by the same person as "XX updated XXX (4 times)". Would be nice to see another pro episode that handled this display related stuff, since my code is kind of messy, and it's be cool to see how it might be implemented by someone else.
I need a litte help.
Where is the rigth place to define the server's address for a remote json ?
tks.
+1
I'm not sure what version of jquery-rails used to produce this error, but it looks like there's an issue with jquery-rails version 2.2.1 and jQuery File Upload 0.4.1. I downgraded to jquery-rails version 2.1.4 and that did the trick.
It looks like in current rails (3.2.12 and sometime since this episode), application.rb now combines the require frameworks into rails/all. This make commenting out require 'rails/test_unit/railtie' problematic. So it runs the tests in default directories (the first test run: partial based on rails defaults).
Per this episode we are loading all the *_test.rb files which allows for the custom directories (the second test run: full).
There is probably a way to do the equivalent of commenting out the rails/test_unit/railtie require without having to be responsible to maintain the other requires that rails/all buys us... however you can get around this for now by adding in minitest.rake: