I managed to do it with an "index.js.erb" file in Rails 4. Just add this coffeescript:
coffeescript
$(window).on 'scroll', ->
if $('.pagination').length
@url = $('.pagination .next_page').attr('href')
if url && $(window).scrollTop() > $(document).height() - $(window).height() - 50
$('.pagination').remove()
$('#articles').append('<div>')
$('#articles div').last().load @url+' #articles', ->
if $('.next_page.disabled').length
$('.pagination').remove()
This loads the next page then uses the pagination on the newly loaded page until there are no more next pages. Just replace "#articles" with the id of your container in the script. Skip the index.js.erb and respond_to jazz.
I've noticed that during deployments, monit will sometimes see that unicorn, sidekiq etc have no pidfiles so will try to start them before the deploy is completed. Does anyone have a solution for this?
I'm thinking of writing a capistrano lockfile when the deploy is started and removing it when finished, then monit can skip its checks for the affected services if the lockfile exists.
hi everyone , this is the first time I ever post something here but before I proceed I need to thank every one kind soul that takes the time to help others, like me, not so experienced; thank you thank you thank you...now I have an app that before I add the code above(calendar) was working fine but now it only works on localhost...I am assuming this something related to heroku so
I looked at heroku logs looking for some hints but I can't figure it out...here is the logs9 at least the first 5 lines)
Starting process with command bin/rails server -p 4543 -e $RAILS_ENV
2013-12-02T22:10:36.246379+00:00 app[web.1]: /app/config/application.rb:5:in <top (required)>': undefined local variable or methodconfig' for main:Object (NameError)
How does Geocoder comply with section 10.1.3b in the Google Maps TOS?
No Pre-Fetching, Caching, or Storage of Content. You must not pre-fetch, cache, or store any Content, except that you may store: (i) limited amounts of Content for the purpose of improving the performance of your Maps API Implementation if you do so temporarily (and in no event for more than 30 calendar days), securely, and in a manner that does not permit use of the Content outside of the Service; and (ii) any content identifier or key that the Maps APIs Documentation specifically permits you to store. For example, you must not use the Content to create an independent database of "places" or other local listings information.
NOTE:
This tutorial example creates a c1.medium instance type on the EC2 and that'll cost $0.145 per Hour.
The image_type for the instance is defined at around line 89 of rubber.yml. To avoid accidental large bill from Amazon, you should choose another instance type from: EC2 pricing
I must be missing something obvious, but although I have got the basic version working fine, I can't figure out how to implement the UI version with all of the built in widgets. Does anyone know how?
I am trying to click a list of links with Mechanize gem, but apparently Mechanize's links_with(criteria) is not properly filtering based on the criteria. For debugging purposes, I am only printing out the link.
The following script is printing out most (all?) links on the page:
ruby
require 'mechanize'
agent = Mechanize.new
url = "http://www.fearlessphotographers.com/location/470/sul-do-brasil"
agent.get(url)
agent.page.links_with(:text => /[VIEW FULL PROFILE]/).each do |link|
puts link.text
end
And if I change the (:text => /[VIEW FULL PROFILE]/) to (:text => "VIEW FULL PROFILE") then no link at all gets printed.
I can't understand what I am doing wrong. Any thoughts?
I have a friend who wrote a Ruby wrapper to the Plotly REST API. You can use it to make interactive, web-based graphs. You can both download your graphs and embed them as an iframe.
Can I enable/disable the alerts only for some paths/controllers ?
I got a lot of alerts on activeadmin and I cannot change that code.
For example I get one for the column :user_type line:
app/admin/admin_users.rb
index do
column :email
column :first_name
column :last_name
column :user_type
default_actions
end
Well I'm a comparative newbie here but with my limited Rails4 work I would suggest whitelisting by doing this (using Ryan's example). In the private area of the books controller add the author_ids to the book_params:
rails
defbook_params
params.require(:book).permit( ... many attributes....,:author_ids => [])
end
hey @ryan! I used your home brew in a rails 4 app, but the self.by_votes method doesn't seem to work. As is... it orders things, but it duplicates each item for each time they've been voted on. I was wondering if you had any ideas?
I'm running into an issue with Rails (v4) images (ex: the arrows) If I put it into assets/images/
do I have to do precompiling? The asset pipeline is really confusing me
Ryan says that actually friendly_id history doesn't work for old records but only for new ones.
That is not true anymore.
You just need to create friendly_id table before adding slug column and save your object.
Like this:
I am having problem with the search function.when search function is assigned the page will reload and can't find out the search element.How to solve this error?.
followed the tutorial, but for the life of me cannot get this to work on rails 3.2.13 and ruby 2.0.0.
basically i get the following error with the controller's 'show' action:
Great railscast! I didn't like the gmail option but found this awesome blog post which explains how to start postfix on your mac and send mail from that - no passwords or environment variables required
I am trying to authenticate using warden for JSON based APIs(web services), I have defined my password strategy inside config/initializers as password_strategy.rb which has authenticate! method defined inside it. When I call this authenticate! method from sessions controller's create method, params inside authenticate! method are getting empty some how although I can see my params inside create method of sessions controller, not sure what magic is happening behind the scene.
Since my params are empty my authentication is detected as unauthorized and I am redirected to sessions new method for logging in again even my login credentials are correct.
I can log in and log out, but I can also use all the links, add content or delete. So my authentication is not quite working right. My app says I'm successfully logged in, or logged out, but it doesn't matter. Either way there is full access to the rest of the app.
I followed all the direction in this tutorial, and thought it was working until I realized I could still do anything as an unlogged user.
I managed to do it with an "index.js.erb" file in Rails 4. Just add this coffeescript:
This loads the next page then uses the pagination on the newly loaded page until there are no more next pages. Just replace "#articles" with the id of your container in the script. Skip the index.js.erb and respond_to jazz.
These posts are over a year old, did anyone find out as to why to use the techniques in this episodes rather than the nest_form gem?
The #196 revised does all this plus the previous video (196) for rails 3, and they mostly work for Rails 4 except for strong parameters adjustments.
No route matches “/users/sign_out” devise rails 3
Solved by :
http://stackoverflow.com/questions/6557311/no-route-matches-users-sign-out-devise-rails-3
I've noticed that during deployments, monit will sometimes see that unicorn, sidekiq etc have no pidfiles so will try to start them before the deploy is completed. Does anyone have a solution for this?
I'm thinking of writing a capistrano lockfile when the deploy is started and removing it when finished, then monit can skip its checks for the affected services if the lockfile exists.
hi everyone , this is the first time I ever post something here but before I proceed I need to thank every one kind soul that takes the time to help others, like me, not so experienced; thank you thank you thank you...now I have an app that before I add the code above(calendar) was working fine but now it only works on localhost...I am assuming this something related to heroku so
I looked at heroku logs looking for some hints but I can't figure it out...here is the logs9 at least the first 5 lines)
Starting process with command
bin/rails server -p 4543 -e $RAILS_ENV
2013-12-02T22:10:36.246379+00:00 app[web.1]: /app/config/application.rb:5:in
<top (required)>': undefined local variable or method
config' for main:Object (NameError)Rails 4
Nice tutorial!
What if I'd like to migrate my users to another authentication system such as 'Devise' later on?
How does Geocoder comply with section 10.1.3b in the Google Maps TOS?
+1 for an extension to this cast... perhaps writing a Spree Extension :)
NOTE:
This tutorial example creates a c1.medium instance type on the EC2 and that'll cost $0.145 per Hour.
The
image_type
for the instance is defined at around line 89 of rubber.yml. To avoid accidental large bill from Amazon, you should choose another instance type from: EC2 pricingthanks for the tip
I must be missing something obvious, but although I have got the basic version working fine, I can't figure out how to implement the UI version with all of the built in widgets. Does anyone know how?
Thanks in advance!
I am trying to click a list of links with Mechanize gem, but apparently Mechanize's
links_with(criteria)
is not properly filtering based on the criteria. For debugging purposes, I am only printing out the link.The following script is printing out most (all?) links on the page:
And if I change the
(:text => /[VIEW FULL PROFILE]/)
to(:text => "VIEW FULL PROFILE")
then no link at all gets printed.I can't understand what I am doing wrong. Any thoughts?
hey Jose,
can you point me to some resources as to how I can accomplish this with js/jquery. :D
I needed to use radio_button_tag and got it to work using Ryan's example with:
File: people_datatable.rb
I have a friend who wrote a Ruby wrapper to the Plotly REST API. You can use it to make interactive, web-based graphs. You can both download your graphs and embed them as an iframe.
It's on GitHub here: https://github.com/plotly.
You can see examples at https://plot.ly.
First two links had changed their address to:
http://errtheblog.com/posts/24-irb-mix-tape
http://errtheblog.com/posts/41-real-console-helpers
Can I enable/disable the alerts only for some paths/controllers ?
I got a lot of alerts on activeadmin and I cannot change that code.
For example I get one for the
column :user_type
line:Hi
How to start resque in verbose mode for production.
Thanks in advance!!
Well I'm a comparative newbie here but with my limited Rails4 work I would suggest whitelisting by doing this (using Ryan's example). In the private area of the books controller add the author_ids to the book_params:
+1
Thanks so much! This definitely helped me out as well.
I am using rails 3.2.1 omniauth-twitter (0.0.9)
But in twitter callback phase I receive this error
TypeError "can't convert nil into String"
I have already updated omniauth-twitter gem and it remains at the same version mentioned above.
What could be the possible reason?
hey @ryan! I used your home brew in a rails 4 app, but the
self.by_votes
method doesn't seem to work. As is... it orders things, but it duplicates each item for each time they've been voted on. I was wondering if you had any ideas?I'm running into an issue with Rails (v4) images (ex: the arrows) If I put it into assets/images/
do I have to do precompiling? The asset pipeline is really confusing me
You'll need to set the time zone to the current user's time zone. It's probably setting it to Heroku's UTC time.
Before creating the calendar, set the time zone in the controller.
Thank you very much Florian!
I don't know if you still need... I used with strong parameters with this:
and it worked. I don't know if it is optimal
Ryan says that actually friendly_id history doesn't work for old records but only for new ones.
That is not true anymore.
You just need to create friendly_id table before adding slug column and save your object.
Like this:
and everything will work fine as expected.
I also suggest, if you don't want to loose old urls, to execute this code after adding frindly_id_slugs and before adding column to articles
current_timestamp if you are using postgresql
I am having problem with the search function.when search function is assigned the page will reload and can't find out the search element.How to solve this error?.
I did everything as given in the tutorial, but somehow i couldn't seem to generate latitude and longitude automatically when i leave the values blank.
Throws an error infact in "show.html.erb" in this particular line
//
<% for location in @location.nearbys(10) %> -> error line
undefined method `each' for nil:NilClass -> error
//
Can any1 pls help. Thanks in advance.
PS: Im using rails 4 so i don't have to write the attr_accessible line. Just to mention.
Dana:
Make sure you have included the code for basic authorization in application_controller.rb
and then make sure to invoke it in all your controllers:
How can you actually load in the comments inside of the div?
thx
Yes I have,
The gem was renamed to "foundation-rails" but still works like the old one.
...
followed the tutorial, but for the life of me cannot get this to work on rails 3.2.13 and ruby 2.0.0.
basically i get the following error with the controller's 'show' action:
and from what i understand there is problem with this line in:
(gem) activerecord-3.2.13/lib/active_record/relation/finder_methods.rb
Any help appreciated. by the way, had the same error when tried to implement friendly_id gem.
Oh i bet he is
How does this work? I am having the same issue getting a Missing Template.
Great railscast! I didn't like the gmail option but found this awesome blog post which explains how to start postfix on your mac and send mail from that - no passwords or environment variables required
http://andr.esmejia.com/posts/20-send-real-mail-with-rails-from-your-development-environment-on-mac-os-x
In brief:
in terminal do
sudo postfix start
In config/environments/development.rb :
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "localhost",
:port => 25,
:domain => "whatever.com",
}
Worked great on Mac OSX Lion, Rails 3.2
Remember to look in your gmail spam folder for the email (on gmail.com not just Mac Mail app)
I'm struggling with how to pass parameters through to the .rb script. Been battling away for weeks now, with no success. :-(
Has anyone been able to install Foundation 5?
Buen vídeo felicitaciones me gusto
Hi there!
I am trying to authenticate using warden for JSON based APIs(web services), I have defined my password strategy inside config/initializers as password_strategy.rb which has authenticate! method defined inside it. When I call this authenticate! method from sessions controller's create method, params inside authenticate! method are getting empty some how although I can see my params inside create method of sessions controller, not sure what magic is happening behind the scene.
Since my params are empty my authentication is detected as unauthorized and I am redirected to sessions new method for logging in again even my login credentials are correct.
Any help would be appreciated.
Thanks in advance.
I can log in and log out, but I can also use all the links, add content or delete. So my authentication is not quite working right. My app says I'm successfully logged in, or logged out, but it doesn't matter. Either way there is full access to the rest of the app.
I followed all the direction in this tutorial, and thought it was working until I realized I could still do anything as an unlogged user.
Any idea where I should look to correct this?
Thank you!
can I use the calendar to have a live update for booking stuff? If so then do I have to use ActionController::Live for it?
Does anyone know how to add totals with this approach?
Did anyone ever figure out how to do this?
I am encountering the same problem. It's a shame that this functionality is broken (or removed) from rails 4.
I think you can do all this server side validation in the carrierwave uploader (as Ryan used carrierwave for this video).