Active Admin not taking precompile assets on production - ruby-on-rails-4

active admin not taking the precompile assets on production even it's present in public assets folder but it's taking different activeadmin.js and activeadmin.css file
Thanks in advance

In production usually public folder behave differently than development and staging. We got same issue our image was working fine on development but when we are doing it on production it was not working.
We moved it from public to assets and divided our scss/js with specific templates. As normally it adds everything in your assets/css file to one combined file.
So check during compile it take all assets files not public files. You can use public folder like normal link with image_Tag '/' So that mean for admin you have to create separate file manifest

Related

VuePress build deletes CNAME file in ./docs needed for Github Pages custom domain

I'm trying to get VuePress to work well with GitHub Pages and a custom domain. I have the site working -- https://www.southertonrr.com (repo) -- as long as I manually add a CNAME file to my output folder ('./dest', or in my case, './docs', because that's where GitHub Pages looks for the site) every time after I issue a build command. Otherwise, I assume the build command deletes everything in my output folder and rebuilds the entire site.
Is there a way to get vuepress build to either leave that file alone, or copy a CNAME file from my ./src to my ./docs? Should I be looking at the configureWebpack config to use webpack to do it? (I'm new to webpack.)
Different product completely, but I noticed that Docusaurus for React has a CNAME config setting that does this for you, so I thought I'd check to see if the VuePress community had something similar.
See relative document
Sometimes you may need to provide static assets that are not directly referenced in any of your Markdown or theme components - for example, favicons and PWA icons. In such cases, you can put them inside .vuepress/public and they will be copied to the root of the generated directory.

Django Admin wont allow me to allocate permissions to Users or Groups

I am using django 1.8.6 and have a new application created in a virtualenv using python manage.py startproject. I have set up my INSTALLED APPS and my database settings (postgresql) and I have run migrate to create the backend. So far all seems fine. I then created a superuser using the createsuperuser command and that all seemed to go fine too. My admin.py file is in place and the content of which is as follows:
from django.contrib import admin
from django.contrib.admin import AdminSite
from myapp.models import mymodel
Class mymodelAdmin(admin.ModelAdmin):
list_display = {col1, col2, col3}
admin.site.register(mymodel, mymodelAdmin)
All what appears to be fairly simple standard stuff, so far so good.
I'm using apache to render my webpages and having configured my virtualhost stuff I can happily log in to my admin page and see everything I have registered plus the default django admin stuff. I can create a new user with no problem and I can create a new Group with no problem. Where I am running into trouble is I ma not able to assign any standard permissions to with my new user or my group. I can see the list of permissions from my database with no problem but the button that I need to click to move a permission from available to assigned seems to be disabled and I cannot find any information anywhere or in any tutorials or blogs that might help me to unravel this issue. I have been able to replicated this on every installation that I have done following various different tutorials but I still end up with the same problem.
Can anyone please shed any light on what I am missing? Thanks in advance.
UPDATE: So there seems to be an issue with my static files. I have yet to create any static files of my own for the app so the only static files are the ones installed when I use pip to install everything. I'm using a virtual environment (env) inside my project and the structure is as follows:
/var/www/<my project>/env
/manage.py
/<my app>/settings.py
/urls.py
/wsgi.py
/templates
/static
/media
My project static directory is empty as I believe that collectstatic should collect all the static files and put them in here. All the other static files are stored in the site-packages directory within my virtual environment but clearly they are not being accessed. Any help on this would be gratefully received.
Problem Solved...Hoorah! This was a tough one because everything looked fine except for one little thing. Permissions! However the issue wasn't with permissions at all. A red herring I'm afraid. The issue was all to do with static files and trying to get your head around what's going on and making sure you've got your paths all sorted.
For newbies the key is to specify your main static files directory as an empty directory. This is intentional as the collectstatic routine will populate it for you. It seems to me that you should run this routine after you have installed any apps or plugins that you have defined in INSTALLED_APPS. This routine will go off and find all the static files that these apps need to work properly and will copy them to your base static directory. (Make sure you set the permissions to this directory properly otherwise it wont write the new sub-directories etc.) Once copied you will see in your static directory a list of sub directories containing each set of static files separately so as they don't override each other. Follow this theory and all will work fine. By extension when you create your own static files for your applications, you should keep them in a separate static directory located in your folder. Within this you should have another directory named the same as your app and all your static files should be stored in there. Then when you run the collectstatic routine again, it will copy all your static files to the base static directory and store them neatly in your own app's sub directory so as not to conflict with others.
So in essence you have two static folders at the following paths:
/var/www//static (left empty at the same level as manage.py)
/var/www///static/
I have read a lot (and torn a lot of hair out) to get to this point. Somewhere I read someone's post who said that the base static directory (the empty one) is a red herring and you should delete it. I believe this is wrong advice.
Phew! Got there and hope this helps someone else.

Access static content of extjs production build in Django static path

I am facing problem with static content such as .png, .jpg files in Django+extjs environment.
I develop my client side in Extjs with sencha environment and test it locally with sencha server (sencha app watch) which works fine and I see the static images on the UI page.
Now I take a production build of that app (sencha app build classic).
It generates two folders.
Classic : This has app.js and CSS,fonts etc...
resources : (Here is the problem) This has static files like images and json files(if any)
Now I copy these two folders to my Django static path and access the app.js and and CSS files from Django's HTML template. This works.
However, The problem is Django is unable to locate the image files that are there in resources folder (mentioned in list item 2).
If the URL is 'localhost:81/app_name', it searches for the images in the below path
localhost:81/app_name/resources/images/abc.png
But is should look in the below path to get these files
localhost:81/static/resources/images/abc.png
What am i missing here? How Do I tell Django/Extjs to search for the static content in localhost:81/static/resources/images/abc.png
Please suggest.

Deploying a Django site with sensitive code on a host

I've been developing a site with sensitive (i.e. proprietary) code on my local machine, testing it using apache2, and I'm finally going to be getting it setup with a web host. I'm a bit wary because of the "Where should this code live?" note here in the Django Tutorial:
Where should this code live?
If your background is in plain old PHP (with no use of modern frameworks), you’re probably used to putting code under the Web server’s document root (in a place such as /var/www). With Django, you don’t do that. It’s not a good idea to put any of this Python code within your Web server’s document root, because it risks the possibility that people may be able to view your code over the Web. That’s not good for security.
Put your code in some directory outside of the document root, such as /home/mycode.
My host told me that I'll be given a /home/ directory, and that the site will live in /home/www. I'm trying to emulate this directory structure on my end before I send everything to him to make sure it goes as smoothly as possible. My question is, if I want all my code to live outside of the /www directory (per the Django tutorial recommendation above), what actually goes inside the /www directory?
My development directory structure is basically this:
project
db
app1
app2
mysite (contains settings.py, wsgi.py, etc.)
static
templates (contains my base.html, and custom templates for admin, etc.)
Where app1 and app2 are Django apps I've developed to plug into mysite. So what folders / files need to go in the home/www directory, and what can safely live in home/mycode?
Your static and media (user-uploaded) folders, robots.txt etc. should be in the www directory. Basically any file that is directly served by your webserver and not through Django. Other files should live outside of this directory.
Your webserver should point all requests that are not found in the www directory towards your wsgi application, which doesn't need the code to be accessible by an url.
The reason for this is that your webserver does not execute the code in a python file, in contrast to php files. If your code lived in your web root, people could read your settings files by just going to example.com/src/settings.py. Images, plain html/text files and javascript should be read, but any code that should be executed should live outside your web root. Django will execute the files and generate the response that a user should actually see.

Making static file serve location configurable in Django?

I'm developing with Django on my computer, and the location of all my static files are different than on my host. Is there a way to make this a configurable parameter?
For example, on my computer, I have to include jquery.js in my templates, which is located in /includes/jquery.js, but on my host, it's located at ../static/jquery.js, but I don't want to make all of these changes for every template page.
There are two questions here. The first is how to configure where Django finds static files, and the URL prefixes used when linking to/including static resources. The answer to that question is to use the MEDIA_URL and MEDIA_ROOT settings to control the URL mapping and on-disk path info for static media. See the Django setting reference docs for more info on that task.
Then, your second implicit question is how to maintain different settings for your local development environment and the production deployment. There are many different "recipes" for maintaining multiple parallel configuration environments for Django projects, but I find the simplest method to simply be adding something like this to the bottom of my settings.py:
try:
from settings_local.py import *
except ImportError:
pass
Then, if either system (dev or production) has a file called settings_local.py in the root project directory, configuration options set there will override those made in the main settings.py. I then usually add the local file to the ignore list for my version control, and put machine-dependent or security-sensitive data (like database passwords) into it, while the bulk of the configuration can live in the main version-controlled settings.py.
Well, Django config files are python scripts, so you have a great fidelity in them. For example, you may want to create list of locations for every host, and read them in your configuration files.
See the djangodose article on configuring development and production environments and specifically the fourth comment. The instructions given specifically address your question of keeping all settings in the VCS - But what if I'm changing the file that has this configurable location? I don't want to put it on my ignore list.