I applied this concept to a has_many_through association. When I EDIT a page, the 'Country' is already selected but the 'State' list isn't filtered. I have to click to another 'Country' for the filter of the 'State' list to take effect.
Anyone know how to have the filtering kick-in upon page load?
I'm wondering if it's possible with this gem to sort by the reputation table (RSEvaluation) only objects that have certain properties, such as created_at > 1.day.ago? Other voting systems offer a tally/query method, but with ar-rep-system I'm struggling to write similar functionality.
Something to keep in mind when trying Celluloid on Heroku is memory usage.
Heroku will restart your processes if they use too much memory, so you'll want to experiment to find the number of threads you can run, that depends on your work load.
I found this when working on heroku with girl_friday. It worked, but it crashed frequently due to memory limits.
Tip: to check if a value is set on a field, Rails provides you with methods that end with a question mark. So your price_in_dollars method will look like this:
ruby
defprice_in_dollars
price_in_cents.to_d/100if price_in_cents?
end
Thanks, but it seems set in my computer, doesn't it?
I ask this question on the stackoverflow as well. Someone said :
"You just add this ENV['FACEBOOK_APP_ID'] = "yourapikey" into config/environments/development.rb or config/environments/production.rb"
When I first started using Rails, the virtual attributes episodes helped me heaps.
But as time goes, I start seeing my model class getting fatter and fatter, and becoming un-manageable (especially with all those AR callbacks). I guess it's a progressive advancement to start using PORO to move the logic out.
I chose Redis for Sidekiq's storage because it's been extremely reliable for me in production. That said, I can't comment on how well or poorly it works when full because I've never hit that edge case and I'd caution against trusting the word of 2-3 year old blog posts. If running out of memory is a worry, you should load test that scenario and see how Redis actually performs.
I was hoping that Facebook lets a user export their friends' email addresses to external apps so that a user can see which of his/her other friends are already using that app. Facebook doesn't allow this, for better or worse (probably to maintain control and to prevent spam).
The above functionality of helping a user find their Facebook friends on your app can still be accomplished, but it requires that both users go through the trouble of connecting their Facebook accounts to your app. This is a significant barrier, I believe.
Maybe some one have tell you but if not I will.
I suppose is a little typo or error.
If you and see in your screencast at 04:30, you will watch this line:
<% f.fields_for :questions do |builder| %>
There is an error on <%, you must use <%=. It's a little issue but it could make you to spend a lot of time trying to solving it.
It's also worth mentioning that Girl Friday (along with a slew of other worker/queueing gems) were also written by Mike Perham. Sidekiq is his latest and greatest attempt at efficient message queueing in Ruby.
You should set an environment variable called FACEBOOK_APP_ID containing your actual id. If you're working on a unix type system you can do that with the export command, but that will set it just for the current session. You can also set the variable right before the rails command: FACEBOOK_APP_ID="your app id" rails s. If you want it to persist you should append the export call to your .bashrc file (or .zshrc or the rc file of your terminal). export FACEBOOK_APP_ID="your app id".
+1... I am hoping the next episode will be "Refactoring Virtual Attributes (and eliminating callbacks.)" I've been reading up a lot on this and think an episode will solidify the concepts!
I realise that you probably want to keep your examples simple and all in one file, but isn't creating categories or tags within the product model considered 'bad form'?
I'd love to see an episode with your take on the current OOP 'movement' in the Rails community - maybe a discussion on how and when you should use POROs etc.
You did some good episodes on design patterns like presenters etc. but a more general look at OOP would be great. Maybe even a multi-part series where you refactor a more complicated real world app?
Mike, thanks for Sidekiq and all your hard work.
It is my understanding that Redis is a memory only database, so if it crashes or the Rails app crashes, then you loose your queues, correct ? I could be wrong here or my info is outdated, please correct me as to how to deal with this kind of situation.
And let me say again, from watching the Railscast, and hearing about it on Ruby5, Sidekiq is awesome.
That'd be really awesome, I've took it for granted it hasn't changed that much, But I'm betting I'm wrong! I too want to see what awesome things you can do with content_for and content_tag
Ty, I'm trying to learn rails. When I put these lines of code in my index nothing show up, so I needed add '=' after <% in form_tag. After that all works great, ty.
I am using devise with omniauth-facebook, it works fine and I can login and logout.
I encountered two errors
1. when it logs in it append #= to window url
2. When I use javascript sdk, as described in this screencast, it shows following error
Could not authenticate you from Facebook because "Csrf detected".
for the first error, a solution on StackOverflow suggest <script type="text/javascript">if (window.location.hash == '#_=_')window.location.hash = '';</script>
is this right approach to handle this bug and how do I resolve csrf detected error when using javascript sdk.
the funny thing is browser and server are setting up secure keys during public negotiation, so hijacker just needs to listen from the begining of the session - he will have all the keys to see HTTPS traffic
A little sad that after so long, jQuery-tokeninput still doesn't support adding new tags.
I needed a simple solution for tagging. The usual Tag => HABTM <= User stuff.
I tried a different solution, using Drew Wilson's Autosuggest and ActsAsTaggableOn. Save the tag tokens as textfields and insert those those as tags.
def tag_tokens=(tags)
# Tag tokens is a method for the JS script to pass in a comma delimited string of tag names
if tags.present?
self.tag_list = [] # For removing tags to work. So tags are re-assigned everytime
self.tag_list << tags.split(",").reject{|t|t.empty?}
end
end
Because ActsAsTaggableOn has those stuff like removing entries without associations etc, so that's all I did.
Thanks for the information.
It helps me to solve the issue of
"NameError: uninitialized constant RAILS_ROOT"
and
"NameError: uninitialized constant RAILS_ENV"
Can someone fill in the gap that occurs around 8:40? I'm using the latest version of the Twitter gem, and when I set up a twitter.rb initializer as specified, and configure environment variables to match up with the lines in the twitter.rb, go into the rails console, and run Twitter.favorites(count: 1) to test things, I get:
Twitter::Error::Unauthorized: This method required authentication...
Did something change in the Gem? Or, are there steps missing from the railscast?
I've basically followed the directions exactly, with the exception that the Gem I use is the latest Twitter Gem, located at github.com/sferik/twitter.
Were Rocket to have an ivar reference back to Launcher, calling #inspect causes an infinite loop. I thought I just wasn't getting it, but everything works fine when I override #inspect in my actor classes. That's several hours of my life I wish I could have back. =)
Is anyone working on a rubber template for sidekiq? This would make deployment to ec2 much easier. I would do it myself if I knew what I as doing with Capistrano (still learning).
hi i followed all the tutorial but when i wanna show the links to vote, it says that function can't accept my voteable model as parameter...maybe it's compulsory that user is the creator of the voteable model? in my app the admin creates voteable resources, the user creates other kind of resources...could someone help me?
Ryan - This information is really important for developers. In a single day, we run tests or refresh the browser hundreds or thousands(!) of times. This leads to frustration and annoyance, but we don't notice it because we are used to it.
Guard and Guard LiveReload removes these repetitive and annoying actions. Making a tiny improvement in something that is repeated many times can seem like a small accomplishment, but I think it has a large effect.
+1
Thanks Ryan, that's brilliant!
I applied this concept to a has_many_through association. When I EDIT a page, the 'Country' is already selected but the 'State' list isn't filtered. I have to click to another 'Country' for the filter of the 'State' list to take effect.
Anyone know how to have the filtering kick-in upon page load?
Has anyone encountered the following errror?
After approving the facebook app, I get:
OmniAuth::Strategies::OAuth2::CallbackError
Anyone help or comments would be greatly appreciated
Stripe is now in Beta for Canada :)
I'm wondering if it's possible with this gem to sort by the reputation table (RSEvaluation) only objects that have certain properties, such as
created_at > 1.day.ago
? Other voting systems offer a tally/query method, but with ar-rep-system I'm struggling to write similar functionality.Something to keep in mind when trying Celluloid on Heroku is memory usage.
Heroku will restart your processes if they use too much memory, so you'll want to experiment to find the number of threads you can run, that depends on your work load.
I found this when working on heroku with girl_friday. It worked, but it crashed frequently due to memory limits.
hi ryan
i try this with mongodb mongoid gem but i m unable to found solution for find
@categories = Category.find(:all, :conditions => ['name LIKE ?', "%#{params[:search]}%"])
i replace it by
@search = params[:search]
@tags = Category.where({name:/"#{@search}"/})
buts its unable to search any result
can you help me on same
thanks in advance
Tip: to check if a value is set on a field, Rails provides you with methods that end with a question mark. So your price_in_dollars method will look like this:
It's a small but neat change.
Also, speaking of prices, there is an excellent gem called
money-rails
for handling that: https://github.com/RubyMoney/money-railsI am assuming you added the require's in your assets for js & css ...
Run rake assets:precompile and see if it errors out?
If that doesn't fix it let me know there is a few other tricks with development mode for the asset pipeline.
I also met some problem .
When I put the first line
OmniAuth.config.logger = Rails.logger
in this file, I runrails s
, and the terminal said:When I delete the first line
OmniAuth.config.logger = Rails.logger
, it works.How can I solve this problem?
Thanks, but it seems set in my computer, doesn't it?
I ask this question on the stackoverflow as well. Someone said :
"You just add this ENV['FACEBOOK_APP_ID'] = "yourapikey" into
config/environments/development.rb
orconfig/environments/production.rb
"What's the different?
+1 here.
When I first started using Rails, the virtual attributes episodes helped me heaps.
But as time goes, I start seeing my model class getting fatter and fatter, and becoming un-manageable (especially with all those AR callbacks). I guess it's a progressive advancement to start using PORO to move the logic out.
I chose Redis for Sidekiq's storage because it's been extremely reliable for me in production. That said, I can't comment on how well or poorly it works when full because I've never hit that edge case and I'd caution against trusting the word of 2-3 year old blog posts. If running out of memory is a worry, you should load test that scenario and see how Redis actually performs.
I'd like to know this as well.
Great job in this railscast!
I was hoping that Facebook lets a user export their friends' email addresses to external apps so that a user can see which of his/her other friends are already using that app. Facebook doesn't allow this, for better or worse (probably to maintain control and to prevent spam).
The above functionality of helping a user find their Facebook friends on your app can still be accomplished, but it requires that both users go through the trouble of connecting their Facebook accounts to your app. This is a significant barrier, I believe.
Fortunately, I found that OmniContacts enables a user to import their email contacts directly to your app: https://github.com/Diego81/omnicontacts/
Hi Ryan
Maybe some one have tell you but if not I will.
I suppose is a little typo or error.
If you and see in your screencast at 04:30, you will watch this line:
There is an error on
<%
, you must use<%=
. It's a little issue but it could make you to spend a lot of time trying to solving it.Greetings from Mexico
It's also worth mentioning that Girl Friday (along with a slew of other worker/queueing gems) were also written by Mike Perham. Sidekiq is his latest and greatest attempt at efficient message queueing in Ruby.
You should set an environment variable called FACEBOOK_APP_ID containing your actual id. If you're working on a unix type system you can do that with the export command, but that will set it just for the current session. You can also set the variable right before the rails command:
FACEBOOK_APP_ID="your app id" rails s
. If you want it to persist you should append the export call to your .bashrc file (or .zshrc or the rc file of your terminal).export FACEBOOK_APP_ID="your app id"
.+1... I am hoping the next episode will be "Refactoring Virtual Attributes (and eliminating callbacks.)" I've been reading up a lot on this and think an episode will solidify the concepts!
Ryan rocks.
I realise that you probably want to keep your examples simple and all in one file, but isn't creating categories or tags within the product model considered 'bad form'?
I'd love to see an episode with your take on the current OOP 'movement' in the Rails community - maybe a discussion on how and when you should use POROs etc.
You did some good episodes on design patterns like presenters etc. but a more general look at OOP would be great. Maybe even a multi-part series where you refactor a more complicated real world app?
Keep up the good work.
Mike, thanks for Sidekiq and all your hard work.
It is my understanding that Redis is a memory only database, so if it crashes or the Rails app crashes, then you loose your queues, correct ? I could be wrong here or my info is outdated, please correct me as to how to deal with this kind of situation.
And let me say again, from watching the Railscast, and hearing about it on Ruby5, Sidekiq is awesome.
That'd be really awesome, I've took it for granted it hasn't changed that much, But I'm betting I'm wrong! I too want to see what awesome things you can do with content_for and content_tag
Sorry, I'm first time to use omniauth. and have question about ENV["FACEBOOK_APP_ID"]
Should I replace FACEBOOK_APP_ID to my facebook app id, or I should set FACEBOOK_APP_ID in somewhere?
Ty, I'm trying to learn rails. When I put these lines of code in my index nothing show up, so I needed add '=' after <% in form_tag. After that all works great, ty.
<% form_tag projects_path, :method => 'get' do %>
<%= text_field_tag :search, params[:search] %>
<%= submit_tag "Search", :name => nil %>
<% end %>
want to know that as well... did you find a solution?
Does anybody know how I can rename the .xls file when using
respond_to do |format|
format.html
format.xls
end
The file is always called as the controller actions...
thanks !
I am using devise with omniauth-facebook, it works fine and I can login and logout.
I encountered two errors
for the first error, a solution on StackOverflow suggest
<script type="text/javascript">if (window.location.hash == '#_=_')window.location.hash = '';</script>
is this right approach to handle this bug and how do I resolve csrf detected error when using javascript sdk.
the funny thing is browser and server are setting up secure keys during public negotiation, so hijacker just needs to listen from the begining of the session - he will have all the keys to see HTTPS traffic
A little sad that after so long, jQuery-tokeninput still doesn't support adding new tags.
I needed a simple solution for tagging. The usual Tag => HABTM <= User stuff.
I tried a different solution, using Drew Wilson's Autosuggest and ActsAsTaggableOn. Save the tag tokens as textfields and insert those those as tags.
Because ActsAsTaggableOn has those stuff like removing entries without associations etc, so that's all I did.
Are Time.zone or I18n.locale thread safe? They seem like class variables, but are used in most Rails apps.
+1
Thanks for the information.
It helps me to solve the issue of
"NameError: uninitialized constant RAILS_ROOT"
and
"NameError: uninitialized constant RAILS_ENV"
I have to do the price_in_cents stuff all the time, so I made priceable. Nothing too special, but still handy
Very nice! How about revising episode #8 "Layouts and Content For" episode?
Can someone fill in the gap that occurs around 8:40? I'm using the latest version of the Twitter gem, and when I set up a twitter.rb initializer as specified, and configure environment variables to match up with the lines in the twitter.rb, go into the rails console, and run Twitter.favorites(count: 1) to test things, I get:
Twitter::Error::Unauthorized: This method required authentication...
Did something change in the Gem? Or, are there steps missing from the railscast?
I've basically followed the directions exactly, with the exception that the Gem I use is the latest Twitter Gem, located at github.com/sferik/twitter.
Great episode.
Thanks heaps!
The validation part is what I looked for a long time, Ryan, thanks very much.
Ryan, you may want to mention this bug since you're using IRB to demonstrate celluloid: https://github.com/celluloid/celluloid/issues/22
Were Rocket to have an ivar reference back to Launcher, calling #inspect causes an infinite loop. I thought I just wasn't getting it, but everything works fine when I override #inspect in my actor classes. That's several hours of my life I wish I could have back. =)
The redcarpet portion simply doesn't work for me. I can't get Pygments.highlight to work when called within redcarpet
Any reason why you could not just call Thread.new instead of using a job queue?
AWESOME !
Hi anyone know how to add advanced search, by name and address ...???
Is anyone working on a rubber template for sidekiq? This would make deployment to ec2 much easier. I would do it myself if I knew what I as doing with Capistrano (still learning).
We've ported resque-status gem to sidekiq. We're gonna open source it soon.
hi i followed all the tutorial but when i wanna show the links to vote, it says that function can't accept my voteable model as parameter...maybe it's compulsory that user is the creator of the voteable model? in my app the admin creates voteable resources, the user creates other kind of resources...could someone help me?
Ryan - This information is really important for developers. In a single day, we run tests or refresh the browser hundreds or thousands(!) of times. This leads to frustration and annoyance, but we don't notice it because we are used to it.
Guard and Guard LiveReload removes these repetitive and annoying actions. Making a tiny improvement in something that is repeated many times can seem like a small accomplishment, but I think it has a large effect.
"…an example that's a little more practical than launching rockets."
Some would argue there are few things more practical than launching rockets!
I had this same issue with factory_girl 3.5.0 and factory_girl_rails 3.5.0.