I don't know much about android, but I would assume you can get the device Id somehow. couldn't you use that as your token and then have your client just send the device id along with the request?
I use the less hacky approach to use production dump in performance tests. I simply introduce benchmark environment. I just:
put require_relative 'test' into /config/environments/benchmark.rb so that benchmark environment mimics test
add proper entry to /config/database.yml
possibly add Bundler.require(*Rails.groups(:test => %w[test benchmark])) to /config/application.rb to get gems loaded
begin my performance_test_helper.rb with ENV["RAILS_ENV"] = "benchmark" ; require_relative '../../config/environment'.
I use RSpec for general testing, so this perfectly works for me. You may need further tweaks (esp. in point 4) if you want to use Test::Unit for other tests too.
I'm curious if this is the "right" approach for me to use for a particular portion of my application.
I have many tasks and many users. Tasks belong to a particular user, but can be completed by multiple users (defined by a manager role over another model).
Anyway, I want users to be able to opt-in/out of being reminded about certain tasks that they either own or manage.
My thought is to do a has_many :through relationship with a reminder join table.
My interface differs from the one in this railscast in that in the presentation of a task list, there would be just a single check box for each task that determines whether the current logged in user will get reminders for the task.
So I see lots of parallels to this railscast, but I can't seem to get to solution that doesn't feel cludgy. Am I on the right path?
Ive been getting the following error "You must supply a valid card" i cant seem to find any info on the stripe docs, have any of you been getting this lately?
I have successfully implemented the calendar with a grouping by start date. However, my events span over weeks. How can I convert my events to span from start date to end date?
When I call recreate_versions! method a new file is generated and older files are kept on uploads directory. What's the best way to remove older files after recreating versions?
I have issue integrating tokeninput facebook them with bootstrap modal. I googled the issue and it looks like a z-index problem. But I cannot get it working after trying every solutions. I would really appreciate if there could be a tutorial on tokeninput with bootstrap (maybe with modal)
I was wondering if any one knows of good solutions for polymorphic HABTM relations. Like the relationship between tags products and articles. I've seen some decent hacks involving join tables but they all require hard coding each evolved model in the join table.
If you don't want to dig through all the modules, use the default:
class Message
include ActiveModel::Model
end
This is pretty handy, because it already extends Naming and Translation, and includes Validations and Conversion. And it comes with a nifty initializer that allows to pass attributes in Message.new(title: "...") and offers a persisted? method.
This is the default behavior when clicking on a link with an href="#". Make sure that whatever javascript your using to add or remove fields includes an event.preventDefault() call. In coffeescript, this should look something like the following for nested fields but can easily be applied to any click event where you need to suppress the default behavior for a given event:
app/assets/javascripts/nested_forms.js.coffee
jQuery ->
$('form').on 'click', '.remove_fields', (event) ->
$(this).prev('input[type=hidden]').val('1')
$(this).closest('fieldset').hide()
event.preventDefault()
$('form').on 'click', '.add_fields', (event) ->
time = new Date().getTime()
regexp = new RegExp($(this).data('id'), 'g')
$(this).before($(this).data('fields').replace(regexp, time))
event.preventDefault()
In the code !params[:redo] is going to evaluate the truthyness of an instance of String. Even though the contents of that string is 'true' or 'false' !params[:redo] will evaluate to false every time. This will cause your users to get stuck in a loop where 'redo' link is always displayed.
I would make the following changes to the rever action.
resource_owner_authenticator do
# Put your resource owner authentication logic here.
# Example implementation:
current_user || redirect_to(login_url)
end
I totally agree, Igor.
I would have a ProductCollection model (not an AR model, but more of a form object wrapping the collection of Product objects) and a ProductCollectionController. It's much cleaner than forcing collection behaviour into the Product and ProductsController classes.
One thing to mention is that in the routes file, the default version has to be the last one to be defined.
I had a problem where I added a v2 on top of v1 and made it the default like this:
routes.rb
...
namespace :api, defaults: { format:'json' } do
scope module: :v2, constraints:ApiConstraints.new(version:2, default:true) do
...
end
scope module: :v1, constraints:ApiConstraints.new(version:1) do
...
endend
...
All V1 requests would be redirected to the V2 Controllers
I'm trying to make the nav-bar collapsible but I'm not sure how to do it. Using the code above did not work. From inspection I see I need to have the toggle element but I'm unsure how to use it.
Did you get anywhere with this?
I don't know much about android, but I would assume you can get the device Id somehow. couldn't you use that as your token and then have your client just send the device id along with the request?
I use the less hacky approach to use production dump in performance tests. I simply introduce
benchmark
environment. I just:require_relative 'test'
into/config/environments/benchmark.rb
so that benchmark environment mimics test/config/database.yml
Bundler.require(*Rails.groups(:test => %w[test benchmark]))
to/config/application.rb
to get gems loadedperformance_test_helper.rb
withENV["RAILS_ENV"] = "benchmark" ; require_relative '../../config/environment'
.I use RSpec for general testing, so this perfectly works for me. You may need further tweaks (esp. in point 4) if you want to use
Test::Unit
for other tests too.I'm curious if this is the "right" approach for me to use for a particular portion of my application.
I have many tasks and many users. Tasks belong to a particular user, but can be completed by multiple users (defined by a manager role over another model).
Anyway, I want users to be able to opt-in/out of being reminded about certain tasks that they either own or manage.
My thought is to do a has_many :through relationship with a reminder join table.
My interface differs from the one in this railscast in that in the presentation of a task list, there would be just a single check box for each task that determines whether the current logged in user will get reminders for the task.
So I see lots of parallels to this railscast, but I can't seem to get to solution that doesn't feel cludgy. Am I on the right path?
Thanks!
@rvsingh, thanks appreciate this, i owe u a beer
The following code works for grouping counts by month:
date_trunc
is a postgresql function.I've yet to find a way to format the date output to
"%b %Y"
instead of the default format.If anyone has a better solution please share!
Ive been getting the following error "You must supply a valid card" i cant seem to find any info on the stripe docs, have any of you been getting this lately?
which app was Rails extracted from?
Another option of RSpec-ing across multiple time zones:
http://approache.com/blog/testing-rails-across-time-zones/
I've found the after_touch method a good place to clear the cache too
I have successfully implemented the calendar with a grouping by start date. However, my events span over weeks. How can I convert my events to span from start date to end date?
Thanks!
When I call recreate_versions! method a new file is generated and older files are kept on uploads directory. What's the best way to remove older files after recreating versions?
I have issue integrating tokeninput facebook them with bootstrap modal. I googled the issue and it looks like a z-index problem. But I cannot get it working after trying every solutions. I would really appreciate if there could be a tutorial on tokeninput with bootstrap (maybe with modal)
Hero
I was wondering if any one knows of good solutions for polymorphic HABTM relations. Like the relationship between tags products and articles. I've seen some decent hacks involving join tables but they all require hard coding each evolved model in the join table.
How do you group count by month?
If you don't want to dig through all the modules, use the default:
This is pretty handy, because it already extends Naming and Translation, and includes Validations and Conversion. And it comes with a nifty initializer that allows to pass attributes in Message.new(title: "...") and offers a persisted? method.
See: https://github.com/rails/rails/blob/master/activemodel/lib/active_model/model.rb
If I include all the JS assets in the head everything seems to broke...
Does it work for you? Have you modify anything else?
Hi Ryan,
Good screencast and help all newbies to learn rails easily.
I am using rails 4 and encountered one problem.
In password_resets_controller.rb you do:
elsif @user.update_attributes(params[:user])
IN console it showing
ActiveModel::ForbiddenAttributesError in PasswordResetsController#update
I don't know how to solve this issue.Please help me to solve this issue.
I have a problem in using the dynamic select menu along with nested attributes. please help me . I have posted my question in http://stackoverflow.com/questions/17546917/how-to-include-both-dynamic-select-menu-and-nested-attributes-together-in-rails
This is the default behavior when clicking on a link with an href="#". Make sure that whatever javascript your using to add or remove fields includes an
event.preventDefault()
call. In coffeescript, this should look something like the following for nested fields but can easily be applied to any click event where you need to suppress the default behavior for a given event:Wonderful screen cast. The instructions on the github page are sort of daunting but you make things crystal clear!
+1
Has anyone know how to move create method into worker?
In the code !params[:redo] is going to evaluate the truthyness of an instance of String. Even though the contents of that string is 'true' or 'false' !params[:redo] will evaluate to false every time. This will cause your users to get stuck in a loop where 'redo' link is always displayed.
I would make the following changes to the rever action.
Can anyone provide anything on this subject? I'm really looking myself.
If you would rather not use rvm or rbenv here's a link on how to build ruby from source:
https://github.com/yerv000/how_to-ruby_from_source
Hello, this is a great course and is working perfectly but I am having trouble with Client-side Image Resizing. I followed:
https://github.com/blueimp/jQuery-File-Upload/wiki/Client-side-Image-Resizing
I added 3 lines but it doesn't work
$("#fileupload").fileupload
disableImageResize: false
imageMaxWidth: 800
imageMaxHeight: 800
...
Does anyone have a working example?
Thank you for any help
Do you know what the tax on SQL would be for this? I just used one reputation to count positive (votes up) and another to count negative (votes down).
second level cache with Rails4 support!
For what it's worth, bootstrap has a SASS version. Take a look at the bootstrap-sass gem.
https://github.com/xrd/ng-rails-csrf
Just for the record, I just found this gem:
https://github.com/arsduo/batch_api
Try uncommenting and putting in values for :web_tools_user and :web_tools_password in rubber.yml. It solved the problem for me.
I use
request.subdomains.first
rather thanrequest.subdomain
as recommended by DHH: http://37signals.com/svn/posts/1512-how-to-do-basecamp-style-subdomains-in-railsIf you use
request.subdomain
and use an IP address as the URL,request.subdomain
will include the IP address.Does anyone know why I get the error:
undefined local variable or method `new_user_session_url' for #Doorkeeper::AuthorizationsController:0x007fef99668bc8
resource_owner_authenticator do
# Put your resource owner authentication logic here.
# Example implementation:
current_user || redirect_to(login_url)
end
I am using Sorcery with Doorkeeper
In the latest version of rspec, I'm getting errors like:
It seems the matcher is not valid anymore?
How would you rewrite it so that it works with the latest rspec?
New subscriber here - Thanks for all your work Ryan
Cage Match - EmberJS vs. Angular http://vimeo.com/68215606
Cage Match - EmberJS vs. Angular http://vimeo.com/68215606
I ran into the exact same issue. Thanks for sharing, really helped me out.
Hi Ryan, Thanks for this great episode. In your submit code:
I think you better use @user.save instead of save!. The reason is that your submit method can then only return true or false:
As someone who reads your code, i dont expect to see user validation errors on password submit method.
I totally agree, Igor.
I would have a ProductCollection model (not an AR model, but more of a form object wrapping the collection of Product objects) and a ProductCollectionController. It's much cleaner than forcing collection behaviour into the Product and ProductsController classes.
One thing to mention is that in the routes file, the default version has to be the last one to be defined.
I had a problem where I added a v2 on top of v1 and made it the default like this:
All V1 requests would be redirected to the V2 Controllers
I'm trying to make the nav-bar collapsible but I'm not sure how to do it. Using the code above did not work. From inspection I see I need to have the toggle element but I'm unsure how to use it.
https://github.com/pokonski/public_activity/wiki/%5BHow-to%5D-Use-custom-fields-on-Activity
You can very much do this. We have a symbol syntax for this:
this will execute the
user
association on the tracked object.Not sure what you mean. Do you want to find activities with a specific owner?
Just to reply, it works for a couple of months now on stable :)
Yes, you can. You can freely extend the Activity model with additional columns and methods from other gems. See the Common examples section in README.