I could use help with creating a style sheet to override the default ones from Magnific Popup (https://github.com/joshuajansen/magnific-popup-rails).
I have the code for a user to select their default_profile_id
from their uploaded images. The problem I have is I need code that will allow the current user to make that decision from their page. For example the current user hovers over their photo, and the text "Make Profile Photo" appears on it (https://s18.postimg.cc/arl81snll/mouse.jpg). I don't know how to create a style sheet or modify what I do have so that this action can work.
Any help with adding this action to the photos would be much appreciated.
Photos Controller:
def new
@photo = Photo.new
end
def create
@photo = Photo.new(params[:photo])
@photo.user = current_user
if @photo.save
flash[:notice] = "Successfully created photos."
redirect_to :back
else
render :action => 'new'
end
end
def resize(width, height, gravity = 'Center')
manipulate! do |img|
img.combine_options do |cmd|
cmd.resize "#{width}"
if img[:width] < img[:height]
cmd.gravity gravity
cmd.background "rgba(255,255,255,0.0)"
cmd.extent "#{width}x#{height}"
end
end
img = yield(img) if block_given?
img
end
end
def edit
@photo = Photo.find(params[:id])
end
def update
@photo = Photo.find(params[:id])
if @photo.update_attributes(paramas[:photo])
flash[:notice] = "Successfully updated photo."
redirect_to @photo.gallery
else
render :action => 'edit'
end
end
def destroy
@photo = Photo.find(params[:id])
@photo.destroy
flash[:notice] = "Successfully destroyed photo."
redirect_to @photo.gallery
end
def choose_default_photo
@photo = Photo.find params[:photo_id]
current_user.default_photo = @photo
redirect_to '/profile' # or wherever I want to send them
end
end
Photo model:
attr_accessible :title, :body, :gallery_id, :name, :image, :remote_image_url
belongs_to :gallery
has_many :gallery_users, :through => :gallery, :source => :user
belongs_to :user
mount_uploader :image, ImageUploader
LIMIT = 5
validate do |record|
record.validate_photo_quota
end
def validate_photo_quota
return unless self.user
if self.user.photos(:reload).count >= LIMIT
errors.add(:base, :exceeded_quota)
end
end
end
User Model:
has_many :photos
belongs_to :default_photo, :class_name => "Photo"
after_create :setup_gallery
private
def setup_gallery
Gallery.create(user: self)
end
end
User Controller:
def new
@user = User.new
end
def show
@user = User.find(params[:id])
end
def destroy
User.find(id_params).destroy
flash[:success] = "User deleted."
redirect_to users_url
end
def choose_default_photo
@photo = Photo.find params[:photo_id]
current_user.default_photo = @photo
redirect_to '/profile'
end
The columns for the photos table are:
id
, created_at
, updated_at
, image
, name
, user_id
Users table has the following related columns:
id
, default_photo_id (integer)