Then every remote link could call something generic like:
$('[data-remote=true]').on('click', function (e) {
e.preventdefault();
$($(this).attr('data-remote')).load($(this).attr('href'));
});
Or it could be more elegantly worked into rails.js. This avoids splitting ajax behaviour into dozens of .js.erb files, and writing format.js for every method in the controller. Sure wish something like that was built into rails.js.
Turbolinks is a great solution and I'm using it in a re-write, but for now I have to deal with a rails 3.1.10 app with loads of .on and e.preventdefaults in application.js
Hey guys I'm getting an error out of the blue, but I'm not finding anything resembling it on the net.
I get an "undefined method `stringify_keys' for [:email, :current_password]:Array" error on this line "@user.update_without_password(devise_parameter_sanitizer.for(:account_update))" .
Only when I try to update user information. Anyone have any ideas?
Look at Sidekiq Status. I tried to make very clean and use at little hooks as possible. It works well with scheduled jobs (perform_at/perform_in). It has nice sidekiq status web UI, allows to kill long running status jobs.
Actually - I am not sure, my 'current_user' is broken right now, the status is not stored, so I never see the "Log out" button, any ideas anyone? I can log-in and sign-up, just can't 'log-out' or get the current_user to work...
Adjusting coordinates for the original resolution can also be done in the backend rather than in the javascript on the front-end. Which is particularly useful if you have your JS in an external CoffeeScript file and not in the view. To do so, modify your crop_command in cropper.rb processor:
ruby
modulePaperclipclassCropper < Thumbnail
...
defcrop_command
target = @attachment.instance
if target.cropping?
ratio = target.photo_geometry(:original).width / target.photo_geometry(:large).width
["-crop", "#{(target.crop_w.to_i*ratio).round}x#{(target.crop_h.to_i*ratio).round}+#{(target.crop_x.to_i*ratio).round}+#{(target.crop_y.to_i*ratio).round}"]
endendendend
I recently wrote a very simple library to handle queuing get/post requests before I stumbled upon this episode. Its nice to be reassured of the approach. If anyone is interested, its available at
Hi Aaron, Thxs for posting - this is very helpful! However, I can't figure out how to make the arrows only appear for the column which is currently being used for sorting? The code that you posted above seems to add arrows to all of the column titles at the same time. Any input on how to fix this so that an arrow only shows on one column at a time would be greatly appreciated. Thxs in advance!
I'm using Rails 4 and made all the changes in the comments, including to the router:
initialize: ->
@collection = new Raffler.Collections.Entries()
@collection.fetch({reset: true})
but the tutorial breaks at the point where I'm trying to load the database and show entries.length is no longer 0 but 8. The app doesn't get updated with the entries.
I also read that indentation matters with Coffesecript, so I am using 2 spaces for each indentation. Is that OK?
I guess what really throws me is: Where are the entries created in db/seed.rb stored? They are not stored in mysql, I'm guessing they are stored on the client, but how can I access them? Should Backbone save them through Rails in mysql? And why does the app not get updated with the entries?
Let's say I had a relationship of Athlete's and Match's where each Match was a contest between two Athletes. Is it appropriate in this case to use HABTM or has_many through: or is it better to just store the two athlete id's in the Match model? Thanks!
Actually, I think your answer is exactly what I'm looking for. Working on a shared github app, I want all the developers to be able to run the site locally so they need to have access to the keys as well. Thanks a million!
Edit: for anyone new to Rails structure, these files are in config/environments.
I think this is till a great solution, but I'd like to suggest you consider using the following in ./config/application.rb instead of a separate initializer:
ruby
# Load application ENV vars and merge with existing ENV vars. Loaded here so can use values in initializers.ENV.update YAML.load_file('config/application.yml')[Rails.env] rescue {}
I'm having the exact same problem. I tried Eric Wanchic's answers below regarding Turbolinks, but it didn't seem to help.
Since it's trying to execute the actual link to the '#' url, my guess is that for some reason the event.preventDefault() is not working because it is still trying to execute the link rather than running the javascript.
You have probably created a Tenant on your local machine, but have you created a Tenant via the Heroku console (or some other method)? When you push to Heroku, it does not push your local data.
I'm running into a strange issue: when my initial page loads, the list is NOT sortable. If I refresh, it becomes sortable and everything works.
I'm using ZURB Foundation in my app. Could there be some sort of conflict?
I'm also pretty fuzzy on javascript, jQuery and the function() call.
Could it be that the list is shown before the document finishes loading? Isn't this solved by the function() call? Why doesn't Ryan have that function() call in his coffee script?
sudo adduser
You can read more about this command in the man pages of your system with man adduser.
You can then add a user to the sudo group with with the command:
sudo adduser sudo
Note that versions of Ubuntu until 11.10 will use admin as group instead of sudo:
Until Ubuntu 11.10, the Unix group for administrators with root privileges through sudo had been admin. Starting with Ubuntu 12.04 LTS, it is now sudo, for compatibility with Debian and sudo itself. However, for backwards compatibility, admin group members are still recognized as administrators.
Is there no in-DOM solution for establishing a target element to load the response? For example:
<%= link_to "Show panda", "images/panda.gif", {remote: true, data-target: '#panda-holder' %>
Then every remote link could call something generic like:
$('[data-remote=true]').on('click', function (e) {
e.preventdefault();
$($(this).attr('data-remote')).load($(this).attr('href'));
});
Or it could be more elegantly worked into rails.js. This avoids splitting ajax behaviour into dozens of .js.erb files, and writing format.js for every method in the controller. Sure wish something like that was built into rails.js.
Turbolinks is a great solution and I'm using it in a re-write, but for now I have to deal with a rails 3.1.10 app with loads of
.on
ande.preventdefault
s in application.jsI'm trying to duplicate the "logged out of FB" error Ryan gets, and I can't. My app won't crash!
Did Facebook do anything to fix that?
Thanks! I don't want to add the error-rescuing code if I don't have to.
Hey there,
You have pointed to unicorn.todo.sock. What is in that file? Where can I find information?
Thanks!
M.
Hey guys I'm getting an error out of the blue, but I'm not finding anything resembling it on the net.
I get an "undefined method `stringify_keys' for [:email, :current_password]:Array" error on this line "@user.update_without_password(devise_parameter_sanitizer.for(:account_update))" .
Only when I try to update user information. Anyone have any ideas?
Just for those who want their program to create the cron
0 9 1 * *
which executes on the first day of each month at 9AM, you can do this.This is the same as
:at => "9am"
but is more humanized.Were you able to figure this out?
To work with the gem's latest update, you have to change the line:
config.middleware.use ExceptionNotification,
to
config.middleware.use ExceptionNotification::Rack,
Assuming this is form for editing users, is there any good reason why I can't do what's below?
Hello Sergey!
Look at Sidekiq Status. I tried to make very clean and use at little hooks as possible. It works well with scheduled jobs (perform_at/perform_in). It has nice sidekiq status web UI, allows to kill long running status jobs.
Actually - I am not sure, my 'current_user' is broken right now, the status is not stored, so I never see the "Log out" button, any ideas anyone? I can log-in and sign-up, just can't 'log-out' or get the current_user to work...
Also noticed (for Rails4):
layouts/application.html.erb, we should be using the instance variable instead for current_user, so it should be "<% if @current_user %>"
I was having this issue, and it could be due to the version of Rails I am using.
I get 'create new user' error: "ActiveModel::ForbiddenAttributesError when creating new user" and I looked it up on StackOverflow: http://stackoverflow.com/questions/17335329/activemodelforbiddenattributeserror-when-creating-new-user
That link solved my problem.
Does this gem work in Rails 4? Documentation is unclear. I could greenfield a 3.2 app if need be.
+1
Would be great to see if anybody has some examples of using carrierwave to process the uploaded file and ship the image versions back to s3.
Adjusting coordinates for the original resolution can also be done in the backend rather than in the javascript on the front-end. Which is particularly useful if you have your JS in an external CoffeeScript file and not in the view. To do so, modify your
crop_command
in cropper.rb processor:I'm looking for the same. I've found these 2 posts helpful, but part 3 is yet to be published:
http://blog.atwam.com/blog/2013/04/27/preparing-a-rails-app-for-deployment-using-chef-solo/
http://blog.atwam.com/blog/2013/06/10/configuring-chef-solo-for-our-servers/
I've also found this post helpful for filling in some of the gaps:
http://teohm.github.io/blog/2013/04/17/chef-cookbooks-for-busy-ruby-developers/
Have you found anything elsewhere?
Best way I've found for running migrations is from the console: http://stackoverflow.com/a/18782615/423384
This bug has been fixed in Rails 4.
This tutorial needs information about how to configure redis to work with resque, otherwise you're going to get errors.
From: http://hafizbadrie.wordpress.com/2011/03/23/implementing-resqueredis-on-rails-3/
defaults: &defaults
host: localhost
port: 6379
development:
<<: *defaults
staging:
<<: *defaults
production:
<<: *defaults
Dir[File.join(Rails.root, 'app', 'jobs', '*.rb')].each { |file| require file }
config = YAML::load(File.open("#{Rails.root}/config/redis.yml"))[Rails.env]
Resque.redis = Redis.new(:host => config['host'], :port => config['port'])
Thank you for this. Took me 2 days to realize I was loooking in the wrong place
I'm having the same issue here; can't figure out what I'm doing wrong. Have
resources :shows do
resources :episodes
end
And am trying to get to a link such as
:slide_url => show_episode_path(@show, @episode)
But for some reason the episode id isn't being added:
started GET "/shows/the-first-show/episodes/" for 127.0.0.1 at 2013-09-12 00:54:30 -0400
I recently wrote a very simple library to handle queuing get/post requests before I stumbled upon this episode. Its nice to be reassured of the approach. If anyone is interested, its available at
https://github.com/brewster1134/jquery.cumin
It currently only supports localstorage, but i plan on supporting cookies and a plain JS object to store the queue in the future.
Feel free to post issues or contribute.
Hi Aaron, Thxs for posting - this is very helpful! However, I can't figure out how to make the arrows only appear for the column which is currently being used for sorting? The code that you posted above seems to add arrows to all of the column titles at the same time. Any input on how to fix this so that an arrow only shows on one column at a time would be greatly appreciated. Thxs in advance!
Has anyone figured out how to insert a new line in a cell using the Microsoft XML approach?
Sorry, pilot error. Redid the tutorial from scratch and it all works. Must have had a typo. Database in sqlite3 solved the other problem.
Worked for me, thanks!
Is there a way to add multiple images under one model?
How to delete an image? I see people are using :remove_image check box, but is there any other way?
Thanks
my buttons vote other comments up....help!
github.com/egong/scribe
I'm using Rails 4 and made all the changes in the comments, including to the router:
initialize: ->
@collection = new Raffler.Collections.Entries()
@collection.fetch({reset: true})
but the tutorial breaks at the point where I'm trying to load the database and show entries.length is no longer 0 but 8. The app doesn't get updated with the entries.
I also read that indentation matters with Coffesecript, so I am using 2 spaces for each indentation. Is that OK?
I guess what really throws me is: Where are the entries created in db/seed.rb stored? They are not stored in mysql, I'm guessing they are stored on the client, but how can I access them? Should Backbone save them through Rails in mysql? And why does the app not get updated with the entries?
Let's say I had a relationship of Athlete's and Match's where each Match was a contest between two Athletes. Is it appropriate in this case to use HABTM or has_many through: or is it better to just store the two athlete id's in the Match model? Thanks!
Actually, I think your answer is exactly what I'm looking for. Working on a shared github app, I want all the developers to be able to run the site locally so they need to have access to the keys as well. Thanks a million!
Edit: for anyone new to Rails structure, these files are in config/environments.
try it with _task.html.erb ;-)
I think this is till a great solution, but I'd like to suggest you consider using the following in ./config/application.rb instead of a separate initializer:
Source:
http://quickleft.com/blog/simple-rails-app-configuration-settings
I have the exact same problem you did. I tried your Tubrolinks suggestion, but it doesn't work.
Where did you add the 'data-no-turbolink' tag?
UPDATE: I have it working now - I had my answer_fields wrapped in a tag rather than a tag
Thanks for your post though, turbolinks is very cool!
I'm having the exact same problem. I tried Eric Wanchic's answers below regarding Turbolinks, but it didn't seem to help.
Since it's trying to execute the actual link to the '#' url, my guess is that for some reason the
event.preventDefault()
is not working because it is still trying to execute the link rather than running the javascript.Anyone know how to fix it?
good!
thanks!
You have probably created a Tenant on your local machine, but have you created a Tenant via the Heroku console (or some other method)? When you push to Heroku, it does not push your local data.
I second that - this worked for me as well, just adding the below gems
bootstrap gem
gem 'therubyracer'
gem 'less-rails'
gem 'twitter-bootstrap-rails'
same here
I'm running into a strange issue: when my initial page loads, the list is NOT sortable. If I refresh, it becomes sortable and everything works.
I'm using ZURB Foundation in my app. Could there be some sort of conflict?
I'm also pretty fuzzy on javascript, jQuery and the function() call.
Could it be that the list is shown before the document finishes loading? Isn't this solved by the function() call? Why doesn't Ryan have that function() call in his coffee script?
Thanks!
+1
+1
First, create the user with:
sudo adduser
You can read more about this command in the man pages of your system with man adduser.
You can then add a user to the sudo group with with the command:
sudo adduser sudo
Note that versions of Ubuntu until 11.10 will use admin as group instead of sudo:
Until Ubuntu 11.10, the Unix group for administrators with root privileges through sudo had been admin. Starting with Ubuntu 12.04 LTS, it is now sudo, for compatibility with Debian and sudo itself. However, for backwards compatibility, admin group members are still recognized as administrators.
I deployed my rails app yesterday on digital ocean.
Here is a pretty good tutorial
https://coderwall.com/p/yz8cha
and I put in a comment at the bottom because the deploy.rb needs to configure rvm capistrano properly.
I hope this may help someone down the line.
Just a heads up, I'm adding this to a Rails 4 project and the params slice portion (e.g.)
Is resulting in
ActiveModel::ForbiddenAttributesError
Seems mass assignment protection might still need to be cared for even though I'm not delegating any security-critical properties.
exactly what I was looking for. thanks!
How is the 3rd step? I'm getting the same problem on windows
Is it something like
git clone
?+1
Most likely missed 'bundle exec sidekiq' like I did initially.
+1