I'm using docker-compose as my development environment for my rails application so I don't need to install the future requirements on my own computer. The problem is that when I run, for example, docker-compose run app rails g migration FooBar, the migration file is created with permission so that I can't edit it without permission, and for me this is a problem, I wish this did not happen.
I understand why this occurs and this is not under discussion, what I want is know if I can create my files through docker-compose without permission to access it.
I don't know if I'm using the docker-compose in a wrong way, I'm a beginner with docker and maybe what I'm wanting to do don't make sense, if that's case could someone tell me how I could proceed to run my rails application and execute rails commands with docker.
Related
After developing in Rails on a virtual Linux machine, I just recently installed Windows Subsystem for Linux. Before the Christmas weekend, it was working just fine, but as of this morning, when I try and start up my rails server, it gives me the following complaint:
Could not load database configuration. No such file - ["config/database.yml"]
Of course, when I go into my config folder, database.yml is there - just like it was last week. So I'm confused why it can't find the file now when it absolutely could find it before. Is this some sort of WSL quirk that makes the file hard to find for some reason?
This is most likely guesswork, but I assume that there is a permission issue. If config/database.yml has insufficient ownership or read-levels, it may not be found by your Rails application.
For further diagnose, I recommend posting the output of:
# Get permission details for your config
ls -laZ config/database.yml
And maybe some details of which user is starting the Rails application (effectively which user owns the Ruby process).
I have installed gitlab with the omnibus package on a Ubuntu-based machine, on which I'm trying to develop a rails app as well. Since gitlab installs ruby and the rails framework for itself, could I be able to use it to create new rails applications? When I run gitlab-rails new app_name under my home directory I get an error message that reads:
/usr/bin/gitlab-rails error: could not load /opt/gitlab/etc/gitlab-rails/gitlab-rails-rc
Either you are not allowed to read the file, or it does not exist yet.
You can generate it with: sudo gitlab-ctl reconfigure
And when I run sudo gitlab-rails new app_name I get:
Can't initialize a new Rails application within the director of another, please change to a non-Rails directory first.
Type 'rails' for help
I've tried to run this under newly created, empty directories, but keep getting the same message. I assume gitlab-rails tries to create the new app under the gitlab project directory for some reason?
As far as I know, this isn't the purpose of the gitlab-rails command and isn't a supported functionality. It'd be a much better idea to create a new Rails app by just using the Rails gem itself.
I'm currently building a Laravel 5.1 system, that is being automatically deployed to several servers in several steps (local, test and production).
Unfortunatly I have an issue with the optimized class loader. During deployment, Composer runs and through the composer.json file, the two commands php artisan clear-compiled and php artisan optimize runs without any problems.
My problem is that Laravel at some time during execution of a page tries to write to /bootstrap/cache/services.json, but this fails since the (systemwise) user that created the folder, is not the same as the user that tries to write to the file (It also doesn't make sense that it tries to optimize, since the optimiser file is already created).
Is is possible to disable the "on-the-fly" class loader optimizer? (And if it is, what are the consequenses?)
Before any "You should just change permissions to ...", then i'd like to point out that it is currently not a viable solution. Everything is versionized, so the folder on the server is named something like server/project/20151122192701/laravel and I don't think our tech guys are intersted in changing permissions every time we commit to production :)
I ended up deleting php artisan clear-compiled and php artisan optimize from the composer.json to prevent the commands from running when committing. I also !services.json to /bootstrap/cache/.gitignore (to make it committable) and committing services.json with new writeable permissions (755).
This is to prevent the deploy user from deleting services.json and recreating it with no-write permissions...
I had some other problems with Laravel also caching views and sessions, but this was solved by caching views in the system temp folder (i know this is probably not the best solution, but it works) and using memcached for sessions.
Whenever I try to create a new rails app I get a permission denied error. Yet when I try running rails as sudo it says rails is not a command. How would I use rails in a protected directory? Thanks.
If the Rails binary is not in a path that sudo can see, it won't run as sudo. This happens a lot on Ubuntu systems where the sudo environment is locked down.
I have no idea why you're having this type of problem though - the 'rails' command is meant to be run during development, and you'd usually not be working in a locked-down directory. My advice is to fix whatever permission problems you're having.
If yo're trying to create a Rails application on a server you don't control, you should know that's not the way Rails developers typically work. We usually develop locally and use some tool like Caipstrano or other scripting tool to pull the code from a version control system onto the server.
Without knowing more specifics, I'm afraid I can't be any more helpful than that. But I hope this clears some things up.
I have a daemon that should run behind my rails app doing db modifications.I implemented that daemon using ruby daemons gem. I want to start that daemon at the start of my app. Whenever my app starts, I need to start that daemon.
How can I do this..?
If you must start it during Rails initialization:
Create a ruby file that will start the daemon. Say invoke_daemon.rb
Put this file in config/initializers/invoke_daemon.rb
However if it isn't mandatory, I would suggest creating a binary executable or a rake task and manually starting it through command line. This way it runs as a separate process. You can simply add it to your deployment scripts for production boxes and on development box run it manually. A few examples would be searchd, the search daemon for sphinx and thinking_sphinx:delayed_delta rake task from thinking_sphinx.
For your knowledge you have to take look of
Rails Life cycle
I have just implemented this thing. I have implemented on Windows7.
I have created one batch file let's say my_batch.bat, which contains ruby command i.e. ruby my_daemon.rb file.
In addition, to execute this file when my app starts , I have just added one statement in environment.rb file which executes that batch file. i.e. system ("my_batch.bat").
But I am not sure that this is a good way to implement this task.