If you want a multi-domain solution, I think you'd do that configuration in your front-end web-server/proxy, configuring nginx/apache to handle multiple vhosts.
Hi. I am trying to implement a reset voting feature. So when a user voted up and clicks again on thumbs up, the vote should be reset. I tried to delete evaluation but it does not work. Any clue or someone implement something similar?
Thanks
In order to test the dynamic generation of error pages, you need to be in production environment, which is incompatible with running your entire test suite, normally in test environment.
Similarly hacking the config.consider_all_requests_local parameter may is not viable except as a short-term hack to see dynamic error pages operating in dev or test environment.
So I found it best to move the ErrorsController and associated views into a Rails engine... that way it can have a test suite of its own, running the tests in production environment.
I would think you resolved it long ago so this is more for anyone else viewing this part of the thread. I improved the RubyMine section out on the Wiki
I think you're right about calling this a hack-fest. I think Ryan was alluding to that in the end, but covered it because it's a new core rails feature. But you have to keep in mind that if you need these services, you're going to have to integrate them somehow. I have found that Faye can be pretty fast, depending on your client side JS and architecture.
Ok, last comment. I think this screencast should have included a complete Announcement resource with views, controller actions and model validations. It was fairly simple to wire up the controller and views to accomplish this. I assume it wasn't done as this screencast was focusing more on the test side. In my case, I used this as a guide to create an announcement function for a client site where the client needs to be able to easily manage his announcements.
Also was surprised by the number of small, but important typos in the ASCIIcast. Depending on your skill level, small mistakes can really throw you for a loop.
I also just realized that later in the screencast after creating the announcement controller at /app/controllers/announcements_controller.rb the first line has protect_from_forgery which doesn't belong. That is already in the application_controller.rb
A bit farther down is a paragraph about: "Before we change current we’ll write some tests for the new functionality." that references /spec/announcement_spec.rb instead of /spec/models/announcement_spec.rb
Following the ASCIIcast and just noticed a typo: "This test fails when we run it as our app doesn’t have an Application model. We’ll generate one now with the fields we use in our test then migrate the database."
Wow! Been a RailsCasts member for about 2 weeks and I cannot believe how helpful it has been. Just when you think Google can answer everything, I stumble back here.
I have been looking for a good solution to conditional validations for almost 2 days. Stack Overflow had dozens of potential answers, but no "great" way to get this done.
To anyone trying to access instance variables from within the datatable controller, pass the instance variable to a method within a helper. For example:
Could someone please help me? I'm stuck early on in this Railscast. I cannot seem to get searching with multiple words working (as at approx 02:15 in the video) even though I am using the exact same code as below:
ruby
defself.text_search(query)
if query.present?
where("name @@ :q or content @@ :q", q: query)
else
scoped
endend
Single word searches work fine, just not two or more. I'm not getting any errors, just no results are returned. Any ideas why this could possibly be?
Tried to add drop-downs for the expiry date and was told by Stripe support "The data-stripe version of Stripe.js doesn't support dropdowns yet (we're working to fix this). In the meantime, feel free to copy the old method from https://gist.github.com/boucher/1750368)"
You don't have a topic_attributes method on every class. You have only one shared method in all controllers and views, called permitted_params. The object returned by that method has methods like topic_attributes inside of it.
Keep in mind that in controllers there is already a shared method called params. I think this solution is very much inline with rails' way of doing things (which you might or might not like).
You are right. Sometimes there where multiple ajax requests.
This script only fires one time, removes the eventlistener on scroll end adds it when finished.
Figured it out! Assets were not compiling correctly. Ignore my previous comment, although this showed me how hard this was to debug. Thanks for the great learning resources Ryan.
If you're using chrome you don't actually need to open a different browser to test, you can just hit cmd+shift+n to open a new incognito window and log in as your test user there.
If I am using paperclip and have an upload option in first step.
Will the attachment be persistent in session/rack or I need to use some temporary table/model to store that file before the complete form is submitted ?
I followed the last episode as well as this one, but I cannot lighten up the header by overriding the @navbar* variables as described. I am able to override @linkColor, but I'm not able to override the other variables. Everything worked fine up to that step, starting from the beginning of the last episode. Any suggestions?
Corey - could you go into a little more detail on the proxy object? I'm looking to do something along the lines of letting users (admins) make new forms for the public to submit data to. Following this screen cast I've got it implemented but I'm a Ruby and RoR n00bie.
I've the situation where what data I need to collect is custom per situation, so hard coding Models isn't an option so I am using the Admin's building of a collection of form fields and then dynamically building a model that is then used to make the form for the public and store the data in Mongodb. I've read a bit on factory design patterns and template patterns but I've not yet tried to apply this within rails to even see if it would work.
Thanks for reporting those inconsistencies, I have corrected the ASCIIcast.
Thanks for reporting that, I've corrected this error in the ASCIIcast.
@laylester, could you please put out a sample/example on Github?
Thanks.
Bharat
for the custom s3 uploader, how would i go about adding attributes to be added along with the created photo. such as user_id and photo_name
it's because capistrano is loading bundler incorrectly.
to fix this, in your Gemfile, add both
gem 'capistrano'
gem 'rvm-capistrano'
In deploy.rb,
insert the following line at the top: require "rvm/capistrano"
it should solve the bundle not found issue
If you want a multi-domain solution, I think you'd do that configuration in your front-end web-server/proxy, configuring nginx/apache to handle multiple vhosts.
Hi. I am trying to implement a reset voting feature. So when a user voted up and clicks again on thumbs up, the vote should be reset. I tried to delete evaluation but it does not work. Any clue or someone implement something similar?
Thanks
+1 for tests
In order to test the dynamic generation of error pages, you need to be in production environment, which is incompatible with running your entire test suite, normally in test environment.
Similarly hacking the config.consider_all_requests_local parameter may is not viable except as a short-term hack to see dynamic error pages operating in dev or test environment.
So I found it best to move the ErrorsController and associated views into a Rails engine... that way it can have a test suite of its own, running the tests in production environment.
For some strange reason I keep getting
ActionView::Template::Error (require_tree argument must be a directory
Does anyone seem to get
ActionView::Template::Error (require_tree argument must be a directory
I would think you resolved it long ago so this is more for anyone else viewing this part of the thread. I improved the RubyMine section out on the Wiki
Hey everyone I figured out another solution. by adding:
listen [::]:80 ipv6only=on default_server;
after the
listing [::]:80
this answer was located here on stackoverflow here:
http://stackoverflow.com/questions/14972792/nginx-nginx-emerg-bind-to-80-failed-98-address-already-in-use
Thanks #Nathan
Fantastic! This is so helpful, Ryan. Thanks.
I think you're right about calling this a hack-fest. I think Ryan was alluding to that in the end, but covered it because it's a new core rails feature. But you have to keep in mind that if you need these services, you're going to have to integrate them somehow. I have found that Faye can be pretty fast, depending on your client side JS and architecture.
Ok, last comment. I think this screencast should have included a complete Announcement resource with views, controller actions and model validations. It was fairly simple to wire up the controller and views to accomplish this. I assume it wasn't done as this screencast was focusing more on the test side. In my case, I used this as a guide to create an announcement function for a client site where the client needs to be able to easily manage his announcements.
Also was surprised by the number of small, but important typos in the ASCIIcast. Depending on your skill level, small mistakes can really throw you for a loop.
I also just realized that later in the screencast after creating the announcement controller at
/app/controllers/announcements_controller.rb
the first line hasprotect_from_forgery
which doesn't belong. That is already in the application_controller.rbA bit farther down is a paragraph about: "Before we change current we’ll write some tests for the new functionality." that references
/spec/announcement_spec.rb
instead of/spec/models/announcement_spec.rb
Following the ASCIIcast and just noticed a typo: "This test fails when we run it as our app doesn’t have an
Application
model. We’ll generate one now with the fields we use in our test then migrate the database."I believe the
Application
should beAnnouncement
While this tutorial is awesome the way it is, it falls flat at one thing that is more than not going to happen to you
Please address Capistrano
@ryanb could you see how to do that please.
If you are using MongoID, than do this in your initializer:
Mongoid::Document.send(:include, ActiveModel::ForbiddenAttributesProtection)
Wow! Been a RailsCasts member for about 2 weeks and I cannot believe how helpful it has been. Just when you think Google can answer everything, I stumble back here.
I have been looking for a good solution to conditional validations for almost 2 days. Stack Overflow had dozens of potential answers, but no "great" way to get this done.
Thanks Ryan!
See my comment below for how to do this.
To anyone trying to access instance variables from within the datatable controller, pass the instance variable to a method within a helper. For example:
I did a crude fix that seems to work. I basically just required the time_duration library from inside models/episode.rb.
Please correct me if this is the wrong approach :)
Is anybody else receiving this error?
To replicate you clone the repo for the episode, go into the after folder and run
I am using ruby 1.9.3-p385 and rbenv.
Could someone please help me? I'm stuck early on in this Railscast. I cannot seem to get searching with multiple words working (as at approx 02:15 in the video) even though I am using the exact same code as below:
Single word searches work fine, just not two or more. I'm not getting any errors, just no results are returned. Any ideas why this could possibly be?
+1
Was easy to debug, but still cost me 10 minutes...
sorry about my comment, I was very angry that day; it works fine and the vids are great
Thanks!
I had the same error - "An unexpected error has occurred. We have been notified of the problem."
I got it working following the Stripe tutorial (https://stripe.com/docs/tutorials/forms) which uses https://js.stripe.com/v2/ and has some differences, including the 'data-stripe' attribute.
Tried to add drop-downs for the expiry date and was told by Stripe support "The data-stripe version of Stripe.js doesn't support dropdowns yet (we're working to fix this). In the meantime, feel free to copy the old method from https://gist.github.com/boucher/1750368)"
You sir, made my day!
No, Pierre's code simply saves you from having to define a method called topic, and a different one called user, with mostly the same implementation.
You don't have a topic_attributes method on every class. You have only one shared method in all controllers and views, called permitted_params. The object returned by that method has methods like topic_attributes inside of it.
Keep in mind that in controllers there is already a shared method called params. I think this solution is very much inline with rails' way of doing things (which you might or might not like).
You are right. Sometimes there where multiple ajax requests.
This script only fires one time, removes the eventlistener on scroll end adds it when finished.
This works with turbolinks.
I am using Morris chart. How do i reverse the values on the Y axis.
I am tracking ranks hence lower the better.
http://www.siterankhistory.com
Where you able to find a solution to this? I'm facing the same problem.
I just had this same issue. My problem was that I was searching for row["id"] but my spreadsheet had "ID" instead.
Figured it out! Assets were not compiling correctly. Ignore my previous comment, although this showed me how hard this was to debug. Thanks for the great learning resources Ryan.
If you're using chrome you don't actually need to open a different browser to test, you can just hit cmd+shift+n to open a new incognito window and log in as your test user there.
Any advice about using Doorkeeper with Active Model Serializers as shown in episode #409?
I think you want to do this
I might be wrong.
Just to clarify Turbolinks will be included by default in a new Gemfile generated with Rails 4 it is not built into the framework
I posted a possible solution for that on stackoverflow
If I am using paperclip and have an upload option in first step.
Will the attachment be persistent in session/rack or I need to use some temporary table/model to store that file before the complete form is submitted ?
Try it:
def data
users.map do |user|
[
link_to(user.name, user),
h(user.email),
link_to("delete", user, method: :delete, data: { confirm: 'Are you sure?' }),
"#{check_box_tag('user[]', user.id)}"
]
end
end
You can tag it as 'slow' and just run it on CI.
That's absolutely the case. I believe Model.new is faster than 'build' method. There's an article about it: http://blog.12spokes.com/web-design-development/how-factorygirl-can-slow-down-your-test-suite-aka-factory-build-vs-blank-activerecord-objects/
https://github.com/railscasts/413-fast-tests/blob/master/screencaster-after/Gemfile.lock
Hope it helps ;)
I followed the last episode as well as this one, but I cannot lighten up the header by overriding the @navbar* variables as described. I am able to override @linkColor, but I'm not able to override the other variables. Everything worked fine up to that step, starting from the beginning of the last episode. Any suggestions?
Corey - could you go into a little more detail on the proxy object? I'm looking to do something along the lines of letting users (admins) make new forms for the public to submit data to. Following this screen cast I've got it implemented but I'm a Ruby and RoR n00bie.
I've the situation where what data I need to collect is custom per situation, so hard coding Models isn't an option so I am using the Admin's building of a collection of form fields and then dynamically building a model that is then used to make the form for the public and store the data in Mongodb. I've read a bit on factory design patterns and template patterns but I've not yet tried to apply this within rails to even see if it would work.