it has good examples of how to do tests. It doesn't take much to customize to get to work with something similar to what is suggested in this screencast.
Ignore the rails part
angular does not depend on rails.
just search for angular testing or angular karma tests
In case it might help someone, in Rails 4.0.0/Ruby 2.0, I was getting this error:
private method 'h' called for #<#Class:0x00000003dcd130:0x000000037ef538>
Instead of delegating h to the view_context, I called it directly like this:
ruby
defdata
products.map do |product|
[
link_to(product.name, product),
ERB::Util.h(product.category),
ERB::Util.h(product.released_on.strftime("%B %e, %Y")),
number_to_currency(product.price)
]
end
Use *= stub mercury.css and //= stub mercury.js to exclude Mercury by default then include it explicitly on editable pages.
This has an advantage over removing the require_tree line in that all your javascript and css files will still be included without having to explicitly add them.
I am just running localhost via rails server, and somehow I can't get any of the subdomains to load any pages. So lets just say if I use user1.example.com:3000 (i run my development on a remote server), the page just doesn't load.
And example.com:3000 works. I've read multiple tutorials, but wasn't able to find an answer to this.
I've also tried this on my windows PC, and have set these in host file 127.0.0.1 subdomain1.localhost.local company.blog.local personal.blog.local, but this doesn't work either.
Pulling my hair out for this. Any help is appreciated!
Hi, I was wondering if the field in the translation table must be the same as the one in the model. Say I want to translate description_en and would wish to have a field description_se on translation table. And further be able to access both attributes from rails admin.
def self.authenticate(email, password)
user = find_by_email(email)
if user && BCrypt::Password.new(user.encrypted_password)==password
user
else
nil
end
end
def encrypt_password
if password.present?
self.encrypted_password = BCrypt::Password.create(password)
end
end
You'll want to set the credentials in the environment as shown in the episode, so you can access them using ENV (and so the actual credentials aren't in the code).
I'm trying this on heroku, but it seems the pub/sub doesn't work . Does anyone use this(ActionController::Live, puma, redis) on heroku. I want some advice.
When I run: e = Event.first in the console it gets me my first event.
Then I run: e.eventcategory_ids I get: NoMethodError: undefined method 'eventcategory_ids' for #<Event:0x00000002b7d660>
I figure that has to work before any of the rest of the stuff from this screencast will work for me... right? Am I missing something here?
Ryan. On behalf of all beginners I am begging you PLEASE stop using Coffeescript. It is hard enough that we have rush to master several techniques simultaneously, people keep overcomplicating stuff which is already hard enough with things like Coffee. Please!!!
DEPRECATION WARNING: Relation#update_all with conditions is deprecated. Please use Item.where(color: 'red').update_all(...) rather than Item.update_all(..., color: 'red').
I am trying to reproduce this approach using simple_form, but I am not sure how to recreate the check boxes using simple_form with all the features Ryan covered in this screencast.
Has anyone done this earlier?
[{:code=>"10478", :messages=>["Invalid Data", "Recurring payments profile description must be provided if the billing agreement type is recurring payments."]}]
I do not want to use my AWS credentials to use directly in carrierwave.rb file as pushing it to Github will make it public. Is there a way to create a private file and call the credentials from there?
uploaded file disappears if validation fails. Is there anyway to handle this as It is not user friendly to ask user to upload file every time validation fails.
I was getting this error because my app was in sandbox mode and I was using real users. Once I created test users and use them instead, it started working.
Great cast.
I don't really like to override the .json mime type to always respond with the datatable-formatted JSON
I suggest aliasing the "text/json" mime type to a new type called something like "datatable"
This leaves .json still functioning as it would
initializers/mime_types.rb
Mime::Type.register_alias "text/json", :datatable
products_controller.rb
respond_to do |format|
format.html
format.json { render json:@products }
format.datatable { render json:ProductsDatatable.new(view_context) }
end
I ran into the problem with Mongoid that Mongodb stores the "id" as "_id":{"$oid":"524d74d31c187026b4000001"}. So not only the tag is different, also the id is nested.
What made it work for me is parsing the instance. See below.
class YourApp.Models.YourModel extends Backbone.Model
Thanks Solomon for your solution ! It works great!
I'd like to use your solution as a scope (because I'd like to make a search not based only on tags).
The problem is that the "all" method breaks chaining scope.
I tried to make a scope like this, but doesn't work (not the expected result) :(
And in anyone else has a similar issue, the solution was simple. I had tried already but not for all my hmts at the same time, so didn't get the right outcome. All you have to do is make an alias like this:
Hi,
a newbie question. Got two models Job and Company. A company has_many jobs and each job belongs_to company. Building a form for Job which has collection select that allows user to select already existing company or create one with three fields i.e. name, info, and logo. So far all i have seen is accepts_nested_attributes_for being used in the form of model with has_many relationship and not belongs_to. I saw ryans create model through textfield railscast and this one but couldn't figure out which approach to go for. I like the create model through textfield but how to create three fields rather than one. Any suggestion would be highly appreaciated.
checkout http://joshdmiller.github.io/ng-boilerplate/#/home
it has good examples of how to do tests. It doesn't take much to customize to get to work with something similar to what is suggested in this screencast.
Ignore the rails part
angular does not depend on rails.
just search for angular testing or angular karma tests
In case it might help someone, in Rails 4.0.0/Ruby 2.0, I was getting this error:
private method 'h' called for #<#Class:0x00000003dcd130:0x000000037ef538>
Instead of delegating h to the view_context, I called it directly like this:
Use
*= stub mercury.css
and//= stub mercury.js
to exclude Mercury by default then include it explicitly on editable pages.This has an advantage over removing the
require_tree
line in that all your javascript and css files will still be included without having to explicitly add them.This is new to Sprockets 2.2.0 and up, I believe.
OK, I fixed it by changing all my eventcategory stuff over to eventcat to keep the naming less likely to get mixed up.
Tire might be retired but this Railscast has dated well. Everything works in Rails 3.2.14.
elasticsearch-ruby doesn't appear to be finished and isn't as well documented.
See Karel Minarik's commit here for some improvements on Ryan's code - https://github.com/karmi/tire/pull/131
I am just running localhost via
rails server
, and somehow I can't get any of the subdomains to load any pages. So lets just say if I use user1.example.com:3000 (i run my development on a remote server), the page just doesn't load.And example.com:3000 works. I've read multiple tutorials, but wasn't able to find an answer to this.
I've also tried this on my windows PC, and have set these in host file
127.0.0.1 subdomain1.localhost.local company.blog.local personal.blog.local
, but this doesn't work either.Pulling my hair out for this. Any help is appreciated!
Hi, I was wondering if the field in the translation table must be the same as the one in the model. Say I want to translate description_en and would wish to have a field description_se on translation table. And further be able to access both attributes from rails admin.
"Match" has been deprecated in Rails 4 and has to be replaced with "Get".
Capistrano has just been updated to 3.0! Any advice?
I replaced the salt with:
def self.authenticate(email, password)
user = find_by_email(email)
if user && BCrypt::Password.new(user.encrypted_password)==password
user
else
nil
end
end
def encrypt_password
if password.present?
self.encrypted_password = BCrypt::Password.create(password)
end
end
You'll want to set the credentials in the environment as shown in the episode, so you can access them using ENV (and so the actual credentials aren't in the code).
As for how to manage the ENV variables, check out http://railscasts.com/episodes/85-yaml-configuration-revised or this gem https://github.com/laserlemon/figaro
What's the best way to handle step-specific javascript code?
I'm trying this on heroku, but it seems the pub/sub doesn't work . Does anyone use this(ActionController::Live, puma, redis) on heroku. I want some advice.
I'm using Ruby 2.0 and Rails 3.2.8 and I can't seem to get the simple has_many through part working.
In my Event model
In my Eventcategory model
In my Categorization model
The tables are all there for all three models.
When I run:
e = Event.first
in the console it gets me my first event.Then I run:
e.eventcategory_ids
I get:NoMethodError: undefined method 'eventcategory_ids' for #<Event:0x00000002b7d660>
I figure that has to work before any of the rest of the stuff from this screencast will work for me... right? Am I missing something here?
In Firefox only.
http://localhost:3000/user_steps/%2E%2F%2E%2E%2F%2E%2E%2Fconfig%2Fdatabase%2Eyml
show database.yml
http://localhost:3000/user_steps/%2E%2F%2E%2E%2F%2E%2E%2F%2E%2E%2F%2E%2E%2Fetc%2Ffstab
show /etc/fstab
...
Ryan. On behalf of all beginners I am begging you PLEASE stop using Coffeescript. It is hard enough that we have rush to master several techniques simultaneously, people keep overcomplicating stuff which is already hard enough with things like Coffee. Please!!!
Tire has been retired. Read the explanation here:
https://github.com/karmi/retire
Looks like there is a replacement:
https://github.com/elasticsearch/elasticsearch-ruby
Would love a Railscast for this, especially since this Tire railscast is almost 2 years old.
I used Daren Serra Dias Warburton's solution to get this working in Rails 4.
Thank you.
With Rails 4 depreciating Relation#update_all, your solution worked.
Rails 4
Hi all,
I am trying to reproduce this approach using simple_form, but I am not sure how to recreate the check boxes using simple_form with all the features Ryan covered in this screencast.
Has anyone done this earlier?
Appreciate the help.
Xiao
same here. tried to download in itunes and says: "This movie requires QuickTime, which is not supported by this version of iTunes."
Use new_user_session_url_path instead.
I am getting this error as well Daniel Gaeta. Not using Sorcery, but I am using Doorkeeper and OmniAuth.
If you're going to session, why not store the whole thing in session, and then add it to their account upon sign up?
No guest accounts needed.
if anyone needs a rake task for generating public pages you can use mine https://github.com/equivalent/forgotten_software/blob/master/2013-10-custom_error_pages/lib/tasks/generate_error_pages.rake
Same here, not working for me either.
[{:code=>"10478", :messages=>["Invalid Data", "Recurring payments profile description must be provided if the billing agreement type is recurring payments."]}]
what does this mean if i get this error
I do not want to use my AWS credentials to use directly in carrierwave.rb file as pushing it to Github will make it public. Is there a way to create a private file and call the credentials from there?
shorthand...
uploaded file disappears if validation fails. Is there anyway to handle this as It is not user friendly to ask user to upload file every time validation fails.
client_side_validations isn't maintained anymore. Does anyone knows a alternative?
I was getting this error because my app was in sandbox mode and I was using real users. Once I created test users and use them instead, it started working.
The Redis subscription keeps blocking my req-res cycle and my browser seems to keep loading for ever. Does any one has this issue? Please help.
Just wondering Rajeev if you found a solution to this? Thanks
For future reference: This happens because the ENV["OAUTH_ID"] ENV["OAUTH_SECRET"] aren't set.
Thank you!! I had the same problem.
Multitenancy using instance variables.
https://gist.github.com/ashraf-majdee/6811863
Great cast.
I don't really like to override the .json mime type to always respond with the datatable-formatted JSON
I suggest aliasing the "text/json" mime type to a new type called something like "datatable"
This leaves .json still functioning as it would
data-source="<%= products_url(format: "datatable") %>"
I ran into the problem with Mongoid that Mongodb stores the "id" as "_id":{"$oid":"524d74d31c187026b4000001"}. So not only the tag is different, also the id is nested.
What made it work for me is parsing the instance. See below.
class YourApp.Models.YourModel extends Backbone.Model
..parse: (your_model) ->
....your_model.id = your_model._id['$oid']
....your_model
(dots are white spaces)
This is important, because the "id" is needed to navigate to update instead of create, etc.
Hope this is helpful to anyone. If there is a better approach, Lmk. Coffee, JS and BB are new to me ;-)
yeah its not working
Thanks Solomon for your solution ! It works great!
I'd like to use your solution as a scope (because I'd like to make a search not based only on tags).
The problem is that the "all" method breaks chaining scope.
I tried to make a scope like this, but doesn't work (not the expected result) :(
scope :tagged_with, lambda { |names|
joins(:taggings,:tags).where(tags: {name: names}).group('articles.id').having(['COUNT(*) >= ?', names.length])
}
Any idea ?
I'm getting the same error.
And in anyone else has a similar issue, the solution was simple. I had tried already but not for all my hmts at the same time, so didn't get the right outcome. All you have to do is make an alias like this:
has_many: reader_persons, :through => :persons, :source => :person
def reader_tokens=(tokens)
self.reader_person_ids = Person.ids_from_tokens(tokens)
end
and similar for writer_persons
Dude! You rock! Thanks for the info.
If you are using these recipes and get an error on
run %q{eval "$(rbenv init -)"}
You can just remove that line and replace the PATH line above with:
See:
Syntax error running rbenv init
and
Running rbenv from capistrano
Thanks for mentioning that. It's useful even over a year later...
Hi,
a newbie question. Got two models Job and Company. A company has_many jobs and each job belongs_to company. Building a form for Job which has collection select that allows user to select already existing company or create one with three fields i.e. name, info, and logo. So far all i have seen is accepts_nested_attributes_for being used in the form of model with has_many relationship and not belongs_to. I saw ryans create model through textfield railscast and this one but couldn't figure out which approach to go for. I like the create model through textfield but how to create three fields rather than one. Any suggestion would be highly appreaciated.
hi, were you able to do that? if so how?
Hi,
I created 2 admin, based on the user role it will be navigated.
I want to create multiple domains. How to make the admin can create domain and populate the views accordingly.