I am getting this when I do cap deploy:setup or bundle exec cap deploy:setup
I am not quite familiar with the scripts used on the railscast, mainly copy and paste/augment path (insert username/projectname) on the root path. I suspect that I configured the scripts incorrectly?
bundle exec cap deploy:setup
triggering load callbacks
* 2013-09-06 01:21:56 executing `deploy:setup'
* executing "mkdir -p /home/deployer2/apps/lintong /home/deployer2/apps/lintong/releases /home/deployer2/apps/lintong/shared /home/deployer2/apps/lintong/shared/system /home/deployer2/apps/lintong/shared/log /home/deployer2/apps/lintong/shared/pids"
servers: ["192.241.241.204"]
[192.241.241.204] executing command
** [out :: 192.241.241.204] bash: /home/deployer2/.rvm/bin/rvm-shell: No such file or directory
command finished in 9ms
failed: "rvm_path=$HOME/.rvm $HOME/.rvm/bin/rvm-shell 'default' -c 'mkdir -p /home/deployer2/apps/lintong /home/deployer2/apps/lintong/releases /home/deployer2/apps/lintong/shared /home/deployer2/apps/lintong/shared/system /home/deployer2/apps/lintong/shared/log /home/deployer2/apps/lintong/shared/pids'" on 192.241.241.204
@psingh: starting at 6:30, the cast explains that if you add "filter_resource_access" to a controller declaration, the gem will automatically take care of that for you.
I'm wondering about the best way to handle very large data imports that can take minutes to parse... The app I'm working on requires handling potentially huge imports consisting of tens/hundreds of thousands of rows.
I'm thinking it makes sense to store the CSV temporarily on upload, and do all the parsing via cron... and somehow notify the user that the import is processing.
I'm pretty new to rails, and I'm not sure the best way to execute.
Anyone have a suggestion?
I am trying to use geocoder gem to geocode address into latitude and longitude. However when I create a new record, it only records the address string but doesn't contain the latitude and longitude of the given address.
I am behind a proxy, but I have my proxy variable set.
I have this working on my local iMac. When I upload to Heroku, the app gets this log when starting up "/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/relation/finder_methods.rb:310:in `find_with_ids': Couldn't find Tenant without an ID (ActiveRecord::RecordNotFound)"
Do I need to do anything special to run this on Heroku?
I would have liked to see validations using AJAX. If the user tried to submit a blank task, I'd want the field highlighted and an error message to be displayed. I'll figure it out but it would have been nice to see the best practices related to this.
Just in case anyone misreads this as I did, "I've found the after_touch method a good place to clear the cache as well" as in I found I need to use both after_commit and after_touch.
Great find on the after_touch callback!
after_commit doesn't get called if you are just touching the record, ie have nested caches that get invalidated through touching.
This might be a very stupid question but unless I'm mistaken this approach requires pre-loading all the values for the dynamic select onto the client... I have too many for this and instead want to hit the server once for the relevant dynamic dropdown data once the primary selection has been made via AJAX.
p.3 in this case should look like (here tags, etc. have polymorphic relations) :
class OrganizationsController < ApplicationController
def index
@organizations = Organization.all
respond_to do |format|
format.json { render :json => @organizations.to_json( :include => [:user, :tags, :emails, :phones] ) }
end
end
end
That's way angular will bind all of your nested attributes
To have access to your models in Angular you have to do:
1. Declare your model in rails .rb file (hope you've done with this)
2. Declare model as resource in route.rb (resources :your_model )
3. Pack it to JSON in Rails Controller
4. Create angular factory with next code angular.module('GarageCRM.resources').factory 'Your_model', ($resource) ->
$resource 'your_model'
That's all. After configuring angular routes (it's pretty simple) you'll have access to any nested model or attribute.
This should help coderberry.me
I had already read the CodeClimate blog entry about fat models. It is a great reference for OO refactoring, but lacks of examples on how to organize the code the Rails way. This RailsCast just covered all things that weren't clear for me. Thanks, Ryan!
Thanks for the update lamont. I agree, things have changed and it's hard to find good documentation. I'm interested in learning how to use berkshelf and chef-solo together but can't find a good tutorial. Can you recommend one?
I have a document that has spanish characters, accents and ñ. Is there way ensure that these are exported correctly? Or better put, how can I change the encoding to 'Latin-1'?
for the user_id, you can do params[:photo][:user_id] = current_user.id or something like that. I'm still trying to figure out how to capture the photo name...
any further notes on this? I added 'content-type' => 'file' as a placeholder, and added the data.form.find('#content-type').val(file.type) to the coffee file above the data.submit()... nada. Images stop uploading.
but I, too, am getting the application/octet-stream warning...
What if you set config.action_dispatch.tld_length = 2 for herokuapp hosted sites, such as staging.rb? For production, I'd assume you won't use herokuapp.com so tld_length = 1 still works?
Yes, you can create a method in Country model that sorts the states by country_name and states_name (execute a query sql), and later call it in your form.
Example: if your new method is called "states_by_country_name_and_state_name"
I'm new to ruby and need some guidance with a task. I have to import data from an excel spreadsheet. That currently works fine. Now I need to add new columns to the spreadsheet and those new columns belong to seperate tables in the database. So, first I need to look-up the foreign key of the value from excel and add it to that respective table. In total when the spreadsheet is imported I am dealing with three tables. How do I go about doing that? Thank you in advance for any guidance, help or examples.
I came here to share the same fix as given by others. I ended up renaming my authorize method to "check_authorization" and renamed my allow, allow? etc... methods to authorize, authorize? etc...
But I created a rails app from scratch following line by line in the railscast and I get an arror "Cannot convert Symbol into Integer" and my params are slightly different when updating a survey:
So I have a feeling it has to do with the "0" that is before the "content" of "questions_attributes" in the source code params but not in my params. What am I doing wrong and how can I fix it?
yeah I would love to find that out too. So far I have been able to test with a rake task by itself but would love to just test everything locally before I deploy
I am getting this when I do cap deploy:setup or bundle exec cap deploy:setup
I am not quite familiar with the scripts used on the railscast, mainly copy and paste/augment path (insert username/projectname) on the root path. I suspect that I configured the scripts incorrectly?
bundle exec cap deploy:setup
triggering load callbacks
* 2013-09-06 01:21:56 executing `deploy:setup'
* executing "mkdir -p /home/deployer2/apps/lintong /home/deployer2/apps/lintong/releases /home/deployer2/apps/lintong/shared /home/deployer2/apps/lintong/shared/system /home/deployer2/apps/lintong/shared/log /home/deployer2/apps/lintong/shared/pids"
servers: ["192.241.241.204"]
[192.241.241.204] executing command
** [out :: 192.241.241.204] bash: /home/deployer2/.rvm/bin/rvm-shell: No such file or directory
command finished in 9ms
failed: "rvm_path=$HOME/.rvm $HOME/.rvm/bin/rvm-shell 'default' -c 'mkdir -p /home/deployer2/apps/lintong /home/deployer2/apps/lintong/releases /home/deployer2/apps/lintong/shared /home/deployer2/apps/lintong/shared/system /home/deployer2/apps/lintong/shared/log /home/deployer2/apps/lintong/shared/pids'" on 192.241.241.204
@psingh: starting at 6:30, the cast explains that if you add "filter_resource_access" to a controller declaration, the gem will automatically take care of that for you.
I am pasting my code here, it does the following
- downloads the file, not only make it in file system
- libre complaint, also windows, and browser
Even though I dont like to write and delete , but with spreadsheet seems like the only solution.
I am pasting my code here, it does the following
- downloads the file, not only make it in file system
- libre complaint, also windows, and browser
Even though I dont like to write and delete , but with spreadsheet seems like the only solution.
ya thanks sagescs
Now csv working fine but when i import Excel(xls) i get below error
invalid byte sequence in UTF-8
for anyone that comes across it... the format that it needs to be in is just a string of ids, separated by commas.
If I want to create a Book manually, how do I pass the Authors manually? An array doesn't seem to work. I'd basically like to do something like:
I need to call the create action from another model... and I can't seem to pass the author_tokens properly.
It's an issue between
roo gem
andrubyzip gem
.You can fix it by adding
to your
Gemfile
.Rails 4 docs give slightly different syntax:
I'm wondering about the best way to handle very large data imports that can take minutes to parse... The app I'm working on requires handling potentially huge imports consisting of tens/hundreds of thousands of rows.
I'm thinking it makes sense to store the CSV temporarily on upload, and do all the parsing via cron... and somehow notify the user that the import is processing.
I'm pretty new to rails, and I'm not sure the best way to execute.
Anyone have a suggestion?
hi all when i import csv or xls
i get below error
hi all when i import csv or xls
i get below error
zip/zipfilesystem
I have the same question. Did you ever figure out a way to do this?
I am trying to use geocoder gem to geocode address into latitude and longitude. However when I create a new record, it only records the address string but doesn't contain the latitude and longitude of the given address.
I am behind a proxy, but I have my proxy variable set.
What could be the problem here ?
I have this working on my local iMac. When I upload to Heroku, the app gets this log when starting up "/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/relation/finder_methods.rb:310:in `find_with_ids': Couldn't find Tenant without an ID (ActiveRecord::RecordNotFound)"
Do I need to do anything special to run this on Heroku?
I would have liked to see validations using AJAX. If the user tried to submit a blank task, I'd want the field highlighted and an error message to be displayed. I'll figure it out but it would have been nice to see the best practices related to this.
Just in case anyone misreads this as I did, "I've found the after_touch method a good place to clear the cache as well" as in I found I need to use both after_commit and after_touch.
Great find on the after_touch callback!
after_commit doesn't get called if you are just touching the record, ie have nested caches that get invalidated through touching.
This might be a very stupid question but unless I'm mistaken this approach requires pre-loading all the values for the dynamic select onto the client... I have too many for this and instead want to hit the server once for the relevant dynamic dropdown data once the primary selection has been made via AJAX.
Is this feasible?
p.3 in this case should look like (here tags, etc. have polymorphic relations) :
class OrganizationsController < ApplicationController
def index
@organizations = Organization.all
respond_to do |format|
format.json { render :json => @organizations.to_json( :include => [:user, :tags, :emails, :phones] ) }
end
end
end
That's way angular will bind all of your nested attributes
I am using:
It is one line not two and it does not use slashes for OS compatibility.
Hello, Jason
To have access to your models in Angular you have to do:
1. Declare your model in rails .rb file (hope you've done with this)
2. Declare model as resource in route.rb (resources :your_model )
3. Pack it to JSON in Rails Controller
4. Create angular factory with next code
angular.module('GarageCRM.resources').factory 'Your_model', ($resource) ->
$resource 'your_model'
That's all. After configuring angular routes (it's pretty simple) you'll have access to any nested model or attribute.
This should help coderberry.me
Changing the pasted in navigation code to this worked for me:
I'm seeing the same thing. The right navigation elements disappear when the page is narrow.
I had already read the CodeClimate blog entry about fat models. It is a great reference for OO refactoring, but lacks of examples on how to organize the code the Rails way. This RailsCast just covered all things that weren't clear for me. Thanks, Ryan!
Rafael Barbolo from Loja Virtual Kauplus
+1 for Teaspoon - just a great tool for testing JavaScript - kudos to @Jeremy.
Everything works up until I switch the source to anything non-local (source: ['foo', 'food', 'four'] works fine).
This is the error I'm seeing in the console while typing for non-local data:
Uncaught TypeError: Property 'source' of object [object Object] is not a function
Any suggestions? My code is almost identical to the screencast.
I found a very nice collection of Foundation themes: http://www.themplio.com/categories/foundation-themes
I see render @incompletetasks, but I didn't see the _incomplete_task.html.erb ? I'm using Rails 3.2.13 and give me missing template error==
Hey Ryan, have you had a chance to reasess your opinion of ActionController::Live since first releasing this cast?
Please explain how is that the best practice
Thanks for the update lamont. I agree, things have changed and it's hard to find good documentation. I'm interested in learning how to use berkshelf and chef-solo together but can't find a good tutorial. Can you recommend one?
For eyample, given your app runs on example.com:80, you could serve faye via proxying from a different vHost (faye.example.com:80 -> localhost:9292).
I have a document that has spanish characters, accents and ñ. Is there way ensure that these are exported correctly? Or better put, how can I change the encoding to 'Latin-1'?
how do I capture
params[:photo][:name]
?for the user_id, you can do
params[:photo][:user_id] = current_user.id
or something like that. I'm still trying to figure out how to capture the photo name...any further notes on this? I added
'content-type' => 'file'
as a placeholder, and added thedata.form.find('#content-type').val(file.type)
to the coffee file above thedata.submit()
... nada. Images stop uploading.but I, too, am getting the application/octet-stream warning...
Did you figure out how to do this?
Can anyone please help me with this question on defining multiples roles depending on instances of a single model?
http://stackoverflow.com/questions/18482747/rails-using-cancan-to-define-multiple-roles-depending-on-instances-of-single-mo/18486809?noredirect=1#18486809
Thanks so much. This saved me a lot of time.
Thank you!
I am only able to import the first column of the csv file Any suggestions?
Not sure if you figured it out, but just ran into the same problem.
in the strong_params method, you must make tags an array
What if you set config.action_dispatch.tld_length = 2 for herokuapp hosted sites, such as staging.rb? For production, I'd assume you won't use herokuapp.com so tld_length = 1 still works?
Yes, you can create a method in Country model that sorts the states by country_name and states_name (execute a query sql), and later call it in your form.
Example: if your new method is called "states_by_country_name_and_state_name"
in the form
<%= f.grouped_collection_select :state_id, Country.order(:name), :states_by_country_name_and_state_name, :name, :id, :name, include_blank: true %>
FYI - JasmineRice repo 2013/1/17 states:
I'm new to ruby and need some guidance with a task. I have to import data from an excel spreadsheet. That currently works fine. Now I need to add new columns to the spreadsheet and those new columns belong to seperate tables in the database. So, first I need to look-up the foreign key of the value from excel and add it to that respective table. In total when the spreadsheet is imported I am dealing with three tables. How do I go about doing that? Thank you in advance for any guidance, help or examples.
I came here to share the same fix as given by others. I ended up renaming my authorize method to "check_authorization" and renamed my allow, allow? etc... methods to authorize, authorize? etc...
Ok, so I downloaded the source code, and when a survey is updated, the params are this:
{"utf8"=>"✓",
"_method"=>"put",
"authenticity_token"=>"yO16xiTDvjH1i4mvgUSK3XiDxiyzHM87PSGZAc57Cu4=",
"survey"=>{"name"=>"Rails Survey",
"questions_attributes"=>{"0"=>{"content"=>"kjhlkjh",
"_destroy"=>"0",
"answers_attributes"=>{"0"=>{"content"=>"kjlk",
"_destroy"=>"false",
"id"=>"2"}},
"id"=>"2"}}},
"commit"=>"Update Survey",
"id"=>"1"}
But I created a rails app from scratch following line by line in the railscast and I get an arror "Cannot convert Symbol into Integer" and my params are slightly different when updating a survey:
{"utf8"=>"✓",
"_method"=>"put",
"authenticity_token"=>"I4IByp+jkutbWSHRM8z5zvLoKQ1AxfoyNhdMxJ02ORg=",
"survey"=>{"name"=>"Test 1",
"questions_attributes"=>{"content"=>""}},
"commit"=>"Update Survey",
"id"=>"1"}
So I have a feeling it has to do with the "0" that is before the "content" of "questions_attributes" in the source code params but not in my params. What am I doing wrong and how can I fix it?
Short gist on installing Spree in a new Rails app: https://gist.github.com/kany/6334724
yeah I would love to find that out too. So far I have been able to test with a rake task by itself but would love to just test everything locally before I deploy