Anthony Candaele
Joined
Activity
I'm getting this error when I try to login:
BCrypt::Errors::InvalidHash in SessionsController#create
I copied the sessions_controller.rb file from the source code. I also created a new user successfully, but it did not fix the issue.
Posted in video about sortable lists
Cool, I would love to see a video on acts_as_list
Posted in video about sortable lists
Hi Chris,
I found the culprit: Turbolinks!
I found the issue by this post on StackOverflow:
...
"The problem was with Rails 4 turbolinks which are enabled by default. When you use them you can not longer lay on jquery.ready() function from js to fire on page load, so you need to use page:load instead or you can install jquery.turbolinks gem which will bind page:load to query.ready()."
...
then I installed this jquery-turbolinks gem and everything is now working as expected.
greetings, and oh by the way, congrats on your merger with OneMonth,
Anthony
Posted in video about sortable lists
no, there are no Javascipt errors in the Chrome Dev Tools console.
However, I have another jQuery related issue. I'm using the matchHeight.js plugin to set equal heights for elements, and here I also notice that sometimes the matchHeight() function only gets called when the page is manually refreshed with the browser refresh button.
So now I start to wonder if those issues could be interrelated somehow.
Posted in video about sortable lists
there's just one more thing I need to solve.
I've noticed that I can only drag items if I manually refresh the page.
So when I visit the page the first time I can not drag items. Only after clicking the browser refresh button, I can drag items.
Maybe this has something to do with the way the script is loaded, or the way the jQuery function is called.
Posted in video about sortable lists
hurray, it's working!!
thanks a lot. This added a much needed piece of functionality to my Rails app.
you made my weekend Chris : )
Anthony
Posted in video about sortable lists
I guess so, I implement this in my view like this:
...
<tbody data-update-url="<%= sort_admin_sections_url %>">
...
the source for my view can be found here: https://github.com/acandael/beautysalonapp2/blob/sortable_list/app/views/admin/sections/index.html.erb
I tested it in my Coffee script with a simple alert, an when I drag and drop a section item, the alert() gets triggered:
jQuery ->
$('#sections tbody').sortable
axis: 'y'
update: ->
alert("I was drag and dropped");
Posted in video about sortable lists
I have this route for the sort action:
resources :sections do
collection { post :sort }
end
my Javascript (Coffeescript-file) looks like this:
app/assets/javascripts/sections.js.coffee
jQuery ->
$('#sections tbody').sortable
axis: 'y'
update: ->
$.post($(this).data('update_url'), $(this).sortable('serialize'))
The route and coffeescript are literally taken from Ryan Bates' Railscast: http://railscasts.com/episodes/147-sortable-lists-revised
Posted in video about sortable lists
I tried it with this sort method:
def sort
params[:section].each_with_index do |id, index|
Section.where(id: id).update_all({position: index+1})
end
render nothing: true
end
But when I drag a section item, I'm seeing this error in the server log:
Started POST "/admin/sections" for 127.0.0.1 at 2014-12-19 14:26:28 +0100
Processing by Admin::SectionsController#create as /
Parameters: {"section"=>["2", "1", "4", "5", "3"]}
Completed 500 Internal Server Error in 1ms
NoMethodError (undefined method permit' for ["2", "1", "4", "5", "3"]:Array):
section_params'
app/controllers/admin/sections_controller.rb:64:in
app/controllers/admin/sections_controller.rb:20:in `create'
I tried to fix this by adding the sections array to the permit method:
params.require(:section).permit(:title, :description, :image, :remove_image, :category_id, { :section => [] })
But that didn't fix it either.
the source code for my Admin::SectionsController is here:
Posted in video about sortable lists
Hi Chris,
How do I call this order_params method on the sort action?
Currently the sort method looks like this:
def sort
params[:section].each_with_index do |id, index|
Section.update_all({position: index+1}, {id: id})
end
render nothing: true
end
Posted in video about sortable lists
Hi Chris,
I'm looking forward to that screencast : )
In the meantime I try your temporary fix.
greetings,
Anthony
Posted in video about sortable lists
Hi,
I'm not sure if this is the right place to post this issue, but I'm looking for a way in my Rails app to reorder items by drag and dropping.
I tried to implement the solution by Ryan Bates in this Railscast:
http://railscasts.com/episodes/147-sortable-lists-revised?view=comments
but it doesn't seem to work in Rails 4.
I am able to drag and drop the rows in my table, but the reordering does not get persisted to the database. When I tail the production log, I'm seeing this server error:
Started POST "/admin/sections" for 127.0.0.1 at 2014-11-13 20:49:51 +0100
Processing by Admin::SectionsController#create as /
Parameters: {"section"=>["3", "4", "6", "2", "5"]}
Completed 500 Internal Server Error in 1ms
NoMethodError (undefined method permit' for ["3", "4", "6", "2", "5"]:Array):
app/controllers/admin/sections_controller.rb:54:insection_params'
app/controllers/admin/sections_controller.rb:15:in `create'
Because reordering items in a Rails app is a common requirement, I would love to see a screencast about this on Gorails, it would benefit a lot of my Rails applications, and as a imagine, a lot of other developers applications.
greetings,
Anthony
Posted in setup Postgres user fails
yeah,
I found good documentation on the Digital Ocean Tutorials:
basically I fixed my problem with:
sudo su - postgres
psql
CREATE ROLE deploy WITH createdb;
then I was able to run
rake db:create on the production server
Posted in setup Postgres user fails
now I'm finally getting it:
sudo su - postgres
createuser --pwprompt
exit
it was the line
createuser --pwprompt
that confuses me, I typed this litteraly in the command line, while I should specify the user I want to create, for instance:
create deploy --pwprompt
I think it would be clearer if it was specified in the deploy guide like this:
create [name of user] --pwprompt
Posted in setup Postgres user fails
@James, I'm not installing Postgres on my development machine, I'm installing it on the production server. For the moment I'm deploying another Rails application, and I'm running in exactly the same problem as mentioned in this post, when I type:
createuser --pwprompt
I'm still getting the error message:
creation of new role failed: ERROR: role "postgres" already exists
ok, I like 'simple' : )
@Chris, @James
The first deploy is a bit swimming in the ocean, lot's of new stuff, and not sure about what's going on. But I'm starting to feel more comfortable right now, and I'm glad I made the switch from Heroku to a Digital Ocean vps. The Rails Deploy Guide on GoRails was an awesome help, and I would recommend it to anybody having to deploy a Rails app for the first time.
Just a question (@Chris) about the the Rails Deploy Guide, is there a special reason that you use Passenger over Unicorn?
greetings, and again thanks a lot for your help!
Anthony
found the solution. The issue was caused because ImageMagick wasn't installed on the server. Installing ImageMagick with this command solved my problem:
sudo apt-get install imagemagick libmagickcore-dev libmagickwand-dev
apparently the errors do appear in the /var/log/nginx/error.log
Everytime I try to upload a image, I get this type of error:
App 11210 stdout: Started PATCH "/admin/researchers/11" for 157.193.240.200 at 2014-09-16 05:55:16 -0400
App 11210 stdout: Processing by Admin::ResearchersController#update as HTML
App 11210 stdout: Parameters: {"utf8"=>"?~\~S", "authenticity_token"=>"some-token=
", "researcher"=>{"active"=>"1", "first_name"=>"Lesley", "last_name"=>"Hustinx", "title"=>"Associate Professor", "bio
"=>"<p><span>Research interestsSociology, civil society, nonprofit sector, citizenship, citizen participation, solida
rity, social capital, volunteering and philanthropy</span><br></p>", "email"=>"lesley.hustinx@ugent.be", "phone"=>"",
"address"=>"", "image"=>#<ActionDispatch::Http::UploadedFile:0x007f9e0b9fb978 @tempfile=#<Tempfile:/tmp/RackMultipar
t20140916-11210-1ijifg0>, @original_filename="lesley_hustinx.jpg", @content_type="image/jpeg", @headers="Content-Disp
osition: form-data; name=\"researcher[image]\"; filename=\"lesley_hustinx.jpg\"\r\nContent-Type: image/jpeg\r\n">, "c
ourse_ids"=>["7", ""], "research_project_ids"=>[""]}, "button"=>"", "id"=>"11"}
App 11210 stdout: Completed 500 Internal Server Error in 21ms
App 11210 stdout:
App 11210 stdout: Errno::ENOENT (No such file or directory - identify):
App 11210 stdout: app/controllers/admin/researchers_controller.rb:30:in `update'
The code of my researchers#update method looks like this:
def update
@researcher = Researcher.find(params[:id])
if @researcher.update_attributes(researcher_params)
redirect_to admin_researchers_path, notice: "you successfully updated the researcher #{@researcher.fullname}"
else
flash[:alert] = @researcher.errors.full_messages.join(' ')
render :edit
end
end
does anyone have an id what the problem might be? I'm using Carrierwave to upload my images to Amazon S3
thanks for your help,
Anthony
Hi,
My currently deployed Rails app seems to have issues with uploading images to Amazon S3 storage through CarrierWave.
I get the familiar "We're sorry, but something went wrong." message.
I checked the nginx log file (/var/log/nginx/error.log), but I don't see any error messages there at today's date.
So my question is where else can I look for error logs?
I sat the
passenger_friendly_error_pages on
but I'm not getting a friendly error page, so I think the issue isn't Passenger related.
thanks for your help,
Anthony