WARNING: Can’t verify CSRF token authenticity rails

You should do this: Make sure that you have <%= csrf_meta_tag %> in your layout Add beforeSend to all the ajax request to set the header like below: $.ajax({ url: ‘YOUR URL HERE’, type: ‘POST’, beforeSend: function(xhr) {xhr.setRequestHeader(‘X-CSRF-Token’, $(‘meta[name=”csrf-token”]’).attr(‘content’))}, data: ‘someData=” + someData, success: function(response) { $(“#someDiv’).html(response); } }); To send token in all requests … Read more

How is attr_accessible used in Rails 4?

Rails 4 now uses strong parameters. Protecting attributes is now done in the controller. This is an example: class PeopleController < ApplicationController def create Person.create(person_params) end private def person_params params.require(:person).permit(:name, :age) end end No need to set attr_accessible in the model anymore. Dealing with accepts_nested_attributes_for In order to use accepts_nested_attribute_for with strong parameters, you will … Read more

bundle install fails with SSL certificate verification error

Update Now that I’ve karma wh..err mined enough from this answer everyone should know that this should have been fixed. re: via Ownatik again bundle install fails with SSL certificate verification error gem update –system My answer is still correct and left below for reference if that ends up not working for you. Honestly the … Read more

Rails: #update_attribute vs #update_attributes

Please refer to update_attribute. On clicking show source you will get following code # File vendor/rails/activerecord/lib/active_record/base.rb, line 2614 2614: def update_attribute(name, value) 2615: send(name.to_s + ‘=’, value) 2616: save(false) 2617: end and now refer update_attributes and look at its code you get # File vendor/rails/activerecord/lib/active_record/base.rb, line 2621 2621: def update_attributes(attributes) 2622: self.attributes = attributes 2623: … Read more

AWS S3: The bucket you are attempting to access must be addressed using the specified endpoint

It seems likely that this bucket was created in a different region, IE not us-west-2. That’s the only time I’ve seen “The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.” US Standard is us-east-1

What’s the best manner of implementing a social activity stream? [closed]

I have created such system and I took this approach: Database table with the following columns: id, userId, type, data, time. userId is the user who generated the activity type is the type of the activity (i.e. Wrote blog post, added photo, commented on user’s photo) data is a serialized object with meta-data for the … Read more