I don't know any more about MongoDB other than what's covered here. How would I decide whether it's relevant to my app and I should go learn more? Right now my app uses MySQL.
Once I become knowledgeable about MongoDB, how would I decide whether using MongoDB is the right choice?
Please help!! I have followed the tutorial verbatim but the published_on date is not showing up in calendar view. Unless i put this code in articles_controller.rb and it only shows entries for current days only. @articles_by_date = Article.all.group_by {|i| i.created_at.to_date}.
Is there a way to show published_on date for current/past and future dates also?
There is also a gem called CsvRecord that serves as a persistance layer between csv files and Ruby classes, either importing or exporting. It also implements validation and associations and it can be used alongside ActiveRecord.
simply remove the following method, if you want to use alias_method. or remove the alias_method call
ruby
deflinkedin
user = User.from_omniauth(request.env["omniauth.auth"])
if user.persisted?
sign_in_and_redirect user
else
session["devise.user_attributes"] = user.attributes
redirect_to new_user_registration_url
endend
This solution is not the best idea for the situation where you have large csv files (like 40k+ rows)
First of all it will parse large files synchronously - which means you have to wait for the webserver response till parsing is done
The second major problem is that each row is inserted in separate transaction - which is obviously slow as hell
So,as for me, I would not recommend to use this technic for large files
One more thing - if gem you using for CSV parsing loads entire file into memory - this memory won't be freed up after conversion (it is one of the major Ruby's problems)
Thanks a lot Ryan for this and the other Railscasts that you have done on deployment.
On Capistrano's from-the-beginning wiki, there is a section on avoiding deploy:cold which says
First of all, deploy:cold was a bad idea. It attempted to do what I have described in this tutorial, but without enough opinions, and without enough options for configuration. I’ve come to the conclusion that setting up a new app on a new machine is not something that can be generically automated.
Update. I went a little farther into the Screencast to see if the code would eventually work. After failing on the very first import, I spit out a CSV file with the IDs, and all columns and with the following code, it works now.
def self.import(file)
CSV.foreach(file.path, headers: true) do |row|
document = find_by_id(row["id"]) || new
document.attributes = row.to_hash.slice(*accessible_attributes)
document.save!
end
end
I ran into a problem immediately, and from what I can tell it is because I am using a pg_search enabled Document model I am trying to import. I also have another form_tag that I use to search Documents on the index page. Everytime I try to import I am getting.
A ActiveRecord::StatementInvalid occurred in documents#import:
PG::Error: ERROR: relation "pg_search_documents" does not exist
LINE 5: WHERE a.attrelid = '"pg_search_documents"'::reg...
If I remove the include PgSearch section from the Document model the CSV import works perfectly fine. How can I resolve this issue?
I got the following error: /blog/app/views/layouts/application.html.erb:16: syntax error, unexpected ':', expecting ')'
...royuser_session_path, method: :delete);@output_buffer.safe...
basically -- the app doesn't like the following line:
<%= link_to "Logout", destroy_user_session_path, method: :delete%>
specifically, does not like "method: :delete" -- remove those, it loads but then errors because the controller isn't found.
It would be cool, but maybe you have to make sure the user changes his email address, the name, and so.
Else, if users need to confirm their email addresses in the "normal signup" (for example), then you are leaving an open back door.
How do you replace the ugly id and replace it with a seo friendly url?. lol it's at the end of the video, thank you Ryan for always thinking about that!
Was noticing that this was not doing anything to standardize the capitalizations so therefore tagname and Tagname are two different things in this implementation, in order to fix this I simply used a before_save to titleize the names with this:
ruby
before_save :titleizedeftitleizeself.name = self.name.titleize
end
Pretty simple but assigning of the name threw me for a loop for a minute. Great cast!
Now I may have missed something obvious, but the one area that seems to be missing is securing the Tenant model.
You only want a none authenticated person to sign up and create a new tenant
You want an existing tenant to only edit, update, and destroy, and only their own account
And then you want the admin to do anything, but that is a special case for many things
So I guess this is all going to be custom code within the controller (ie force the id in edit, update, and destroy. Only allow new and create if current_id does not exist)
Actually when you play with such DBs there is no need for STI cause there are no tables. And class inheritance becomes really good and natural approach then.
I don't know any more about MongoDB other than what's covered here. How would I decide whether it's relevant to my app and I should go learn more? Right now my app uses MySQL.
Once I become knowledgeable about MongoDB, how would I decide whether using MongoDB is the right choice?
Thanks!
I have the same problem with you .
I get a ReferenceError: event is not defined loading the page as soon as I add the code to implement "remove" in javascript. From Firebug:
(function() {
jQuery(function() {
$('form').on('click', '.remove_fields', function(event) {});
$(this).prev('input[type=hidden]').val('1');
$(this).closest('fieldset').hide();
return event.preventDefault();
});
}).call(this);
Anyone have any idea what's going on? Any help appreciated.
Error after installing bootstrap, can someone help ps? I'm using Rails 3.2.9, therubyracer already installed:
LoadError in Products#index
Showing C:/.../store/app/views/layouts/application.html.erb where line #5 raised:
cannot load such file -- less
(in C:/.../store/app/assets/stylesheets/bootstrap_and_overrides.css.less)
Extracted source (around line #5):
4: Store
5: <%= stylesheet_link_tag "application", :media => "all" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %>
Please help!! I have followed the tutorial verbatim but the published_on date is not showing up in calendar view. Unless i put this code in articles_controller.rb and it only shows entries for current days only. @articles_by_date = Article.all.group_by {|i| i.created_at.to_date}.
Is there a way to show published_on date for current/past and future dates also?
There is also a gem called CsvRecord that serves as a persistance layer between csv files and Ruby classes, either importing or exporting. It also implements validation and associations and it can be used alongside ActiveRecord.
https://github.com/lukasalexandre/csv_record
Unlike AASM and Workflow, state_machine supports multiple state machines at same object/class.
simply remove the following method, if you want to use alias_method. or remove the alias_method call
Why don't you use the find or create syntax in the product model instead of doing find || new ?
It would be interesting to see some data on how much Tubolinks speeds up a real site.
Turbolinks Test seems to run locally, where the request time is about 20ms (on your computer). But in real use it is about 0.5 to 1 sec.
This solution is not the best idea for the situation where you have large csv files (like 40k+ rows)
First of all it will parse large files synchronously - which means you have to wait for the webserver response till parsing is done
The second major problem is that each row is inserted in separate transaction - which is obviously slow as hell
So,as for me, I would not recommend to use this technic for large files
One more thing - if gem you using for CSV parsing loads entire file into memory - this memory won't be freed up after conversion (it is one of the major Ruby's problems)
Great example, how would we accommodate custom mapping vs static header mapping?
Someone mentioned this already, but it wasn't clear until I found this StackOverFlow answer. To sign_out, you must specify the method as 'delete'.
See http://stackoverflow.com/a/6557627/1316635
Why do
require 'csv'
in application.rb and not in product.rb where it's actually used?Thanks a lot Ryan for this and the other Railscasts that you have done on deployment.
On Capistrano's from-the-beginning wiki, there is a section on avoiding
deploy:cold
which saysRyan, would you suggest to avoid
deploy:cold
?Update. I went a little farther into the Screencast to see if the code would eventually work. After failing on the very first import, I spit out a CSV file with the IDs, and all columns and with the following code, it works now.
I ran into a problem immediately, and from what I can tell it is because I am using a pg_search enabled Document model I am trying to import. I also have another form_tag that I use to search Documents on the index page. Everytime I try to import I am getting.
If I remove the include PgSearch section from the Document model the CSV import works perfectly fine. How can I resolve this issue?
The relevant portion from Document.rb:
You can also add another newline between the object declaration and the call to createToken.
It sounds like you don't have your CORS setup right (or at all). Check that you're using the right Origin Domain (as specified in the CORS policy).
Also you should use https://s3.amazonaws.com/xyz instead as you'll get invalid certs for https://xyz.s3.amazonaws.com.
Have sometimes problem with "Cannot allocate memory" when mail sending or image uploading... but I have 1 Gb ram for not high loaded app :(
You have this:
<%= link_to "Logout", destroy_user_session_path, method: :delete%>
Try this instead:
<%= link_to "Logout", destroy_user_session_path, method: :delete %>
You might want to use stackoverflow for help with these questions in the future. You'll probably get a faster and more helpful response.
Hi there, how can i get load_and_authorize_resource working with this from cancan?
attr_accessor :crop_x, :crop_y, :crop_w, :crop_h
attr_accessible :crop_x, :crop_y, :crop_w, :crop_h
+1 This saved my day...I tried using the store_accessor that activerecord provides and it didn't work. This worked perfectly!
I got the following error: /blog/app/views/layouts/application.html.erb:16: syntax error, unexpected ':', expecting ')'
...royuser_session_path, method: :delete);@output_buffer.safe...
basically -- the app doesn't like the following line:
<%= link_to "Logout", destroy_user_session_path, method: :delete%>
specifically, does not like "method: :delete" -- remove those, it loads but then errors because the controller isn't found.
They are available as a gem now:
https://github.com/tvdeyen/capistrano-maintenance
More Details on why the where removed and what went wrong:
https://github.com/capistrano/capistrano/commit/4ece7902d5
I'd like to see that tutorial too.
Hi,
just wondering if someone might be able to answer this?
1) how to prevent certain file type from being uploaded to AWS S3?
For example, i don't want user to upload video file at all, how to prevent it?
2) Is there a way in AWS S3 upload script to stop the files upload from triggering if each user is limit to 5 files upload per user?
Thanks for the help :- )
I would also recommend the mongoid-ancestry gem for Mongoid based Rails apps.
It would be cool, but maybe you have to make sure the user changes his email address, the name, and so.
Else, if users need to confirm their email addresses in the "normal signup" (for example), then you are leaving an open back door.
This is really awesome, thanks!
How do you replace the ugly id and replace it with a seo friendly url?. lol it's at the end of the video, thank you Ryan for always thinking about that!
Just subscribed because I needed to do this exact task. I'm not disappointed I signed up! Good episode thanks!
This is a great way to get the "other" side of a polymorphic has_many.
I suppose that if you can decide the value of the evaluation, you could use this gem for rating 1-5 stars right? or would it be crazy?
awesome you're bringing more attention to
action_missing
...it is the magic by which my gem blue_velvet works.Was noticing that this was not doing anything to standardize the capitalizations so therefore tagname and Tagname are two different things in this implementation, in order to fix this I simply used a before_save to titleize the names with this:
Pretty simple but assigning of the name threw me for a loop for a minute. Great cast!
Or you can use pure CSS to highlight current page based on nested classes.
E.g, body.products > nav.item
Highlight nav.item.products when the body is also products.
The RSS at the top right of the page will give you a personalised link containing the pro episodes.
http://railscasts.com/subscriptions/...../episodes.rss
This is great, however how can I maintain the non subdomain portion?
I'd like that to exist still as a master backend?
Hello!
Does anybody know if Travis CI will run this type of tests? Having a lot of trouble finding info. on that particular subject.
Looks like a good idea, I'll use it in my future projects!
Now I may have missed something obvious, but the one area that seems to be missing is securing the Tenant model.
You only want a none authenticated person to sign up and create a new tenant
You want an existing tenant to only edit, update, and destroy, and only their own account
And then you want the admin to do anything, but that is a special case for many things
So I guess this is all going to be custom code within the controller (ie force the id in edit, update, and destroy. Only allow new and create if current_id does not exist)
thoughts?
Actually when you play with such DBs there is no need for STI cause there are no tables. And class inheritance becomes really good and natural approach then.
I've build a solution:
http://stackoverflow.com/questions/13660058/ruby-on-rails-js-input-token-an-issue-when-validation-fails
Hope it helps to someone, or spark some ideas on other implementations. :)
And if you use fragment caching, you should highlight current page in menu using javascript.
Thanks!!
Shouldn't be the line in the notes
changed to
?
Found it
selectable_column
inside the index do blockHey does anyone know how to show the selection toggle next to each row for batch actions when using the custom table columns.
This is there by default but disappears as soon as we customize. I'm not able to find it in the documentation.