Darion Wood
Joined
Activity
arget_date = Date.today.beginning_of_month
target_range = target_date..target_date.end_of_month
Post.where(created_at: target_range).group_by_week(:created_at, range: target_range).sum(:view_count)
I'm using group_by_week() that is included with groupdate gem. The issue is, its returning records from the end of the last month for certain months. Given that certain months begin on Wednesday. I would like to get all record for example: The month of July 1st-31st and then get the sums for each week within the month. Week 1, should start on July 1st.
Updating the show action when a response is sent back. ActionCable is not rendering the template partial.
Anyone know why ActionCable throttles the memory of my ubuntu 16.04 server. I'm using phusion passenger and nginx. I saw some instructions for setting up actioncable, but I didn't know it would be mandatory. But yes, I would like to see the gist you have for setting up action cable for incoming responses. Thanks.
I know Chris is kind of busy, but I've been trying for two weeks to link ActionCable up to the TwilioController. Has anyone successfully done this?
Can you use actioncable for when a response comes in? If so, would you be able to post a simple gist snippet for it?? Thanks
Alright, I'll give it a test run and post code if any isues surface. Best
Greetings Chris,
I've been using simple_calendar gem for a while -- its a wonderful solution. I was wondering...Can you implement a dropdown list for the months/years for the calendar itself. I think it would be easier to navigate if it included a range for months/years. It could simply add 1+ year if for instance we're in 2019 and 2020 is coming up.
Best,
DW
For some odd reason, I receive "Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. - configuration has an unknown property 'resolvedModules'. These properties are valid:" Has anyone seen this error before?
package.json
{
"name": "sample_app",
"private": true,
"dependencies": {
"@client-side-validations/client-side-validations": "^0.1.1",
"@client-side-validations/simple-form": "^0.1.1",
"@fortawesome/fontawesome-free": "^5.12.1",
"@rails/actioncable": "^6.0.0-alpha",
"@rails/activestorage": "^6.0.0-alpha",
"@rails/webpacker": "^5.0.0",
"@yaireo/tagify": "yaireo/tagify",
"active_storage_drag_and_drop": "^0.4.1",
"chart.js": "^2.9.3",
"chartkick": "^3.2.0",
"cocoon": "github:nathanvda/cocoon#c24ba53",
"flow-webpack-plugin": "^1.2.0",
"jquery": "^3.4.1",
"jquery-ujs": "latest",
"moment": "^2.24.0",
"owl.carousel": "^2.3.4",
"stimulus": "^1.1.1",
"webpack": "^4.42.1"
},
"version": "0.1.0",
"devDependencies": {
"webpack-dev-server": "^3.9.0"
}
}
webpacker.yml
# Note: You must restart bin/webpack-dev-server for changes to take effect
default: &default
source_path: app/javascript
source_entry_path: packs
public_root_path: public
public_output_path: packs
cache_path: tmp/cache/webpacker
check_yarn_integrity: false
webpack_compile_output: false
# Additional paths webpack should lookup modules
# ['app/assets', 'engine/foo/app/assets']
resolved_paths: ['app/assets']
# Reload manifest.json on all requests so we reload latest compiled packs
cache_manifest: false
# Extract and emit a css file
extract_css: false
static_assets_extensions:
- .jpg
- .jpeg
- .png
- .gif
- .tiff
- .ico
- .svg
- .eot
- .otf
- .ttf
- .woff
- .woff2
extensions:
- .erb
- .mjs
- .js
- .sass
- .scss
- .css
- .module.sass
- .module.scss
- .module.css
- .png
- .svg
- .gif
- .jpeg
- .jpg
development:
<<: *default
compile: true
# Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules
check_yarn_integrity: true
# Reference: https://webpack.js.org/configuration/dev-server/
dev_server:
https: false
host: localhost
port: 3035
public: localhost:3035
hmr: false
# Inline should be set to true if using HMR
inline: true
overlay: true
compress: true
disable_host_check: true
use_local_ip: false
quiet: false
headers:
'Access-Control-Allow-Origin': '*'
watch_options:
ignored: '**/node_modules/**'
test:
<<: *default
compile: true
# Compile test packs to a separate directory
public_output_path: packs-test
production:
<<: *default
# Production depends on precompilation of packs prior to booting for performance.
compile: false
# Extract and emit a css file
extract_css: true
# Cache manifest.json for performance
cache_manifest: true
production.js
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
const environment = require('./environment');
module.exports = environment;
Posted in Repost / Retweet / Reblog Discussion
Posted in Repost / Retweet / Reblog Discussion
The code that I have below is for the _message.html.erb partial
<div class="media">
<% if message.user.user_profile.avatar.profile_thumb.present? %>
<%= image_tag message.user.user_profile.avatar.profile_thumb, class: "d-flex align-self-start mr-3 img-thumbnail rounded" %>
<% else %>
<img class="d-flex align-self-start mr-3 purple-rounded rounded" src="http://via.placeholder.com/30x30">
<% end %>
<div class="media-body">
<h5 class="mt-0">
<%= message.user.username %>
</h5>
<p>
<%= message.body %>
</p>
</div>
</div>
The code below is from chatroom.coffee file.
App.chatrooms = App.cable.subscriptions.create "ChatroomsChannel",
connected: ->
# Called when the subscription is ready for use on the server
disconnected: ->
# Called when the subscription has been terminated by the server
received: (data) ->
active_chatroom = $("[data-behavior='messages'][data-chatroom-id='#{data.chatroom_id}']")
if active_chatroom.length > 0
if document.hidden
if $(".strike").length == 0
active_chatroom.append("<div class='strike'><span>Unread Messages</span></div>")
if Notification.permission == "granted"
new Notification(data.username, {body: data.body})
else
App.last_read.update(data.chatroom_id)
# Insert the message
active_chatroom.append("<div class='media'><div class='media-body'><h5 class='mt-0'>#{data.username}</h5> <p>#{data.body}</p></div></div>")
else
$("[data-behavior='chatroom-link'][data-chatroom-id='#{data.chatroom_id}']").css("font-weight", "bold")
send_message: (chatroom_id, message) ->
@perform "send_message", {chatroom_id: chatroom_id, body: message}
The message body and user name appends correctly. But, I have to refresh to see the user avatar or the placeholder image. It does not insert the entire partial view. I've been working hard to figure this out, and now I'm puzzled.
Care to help me out? Thanks
The documentation for this gem is very shotty, and I can barely understand If you can help me setup the methods for the controller, views, toggle on and off follow button, and blocking users. That would be great. Thanks!
Posted in Issues with JQuery AtWho
Thanks!
Posted in Issues with JQuery AtWho
Alright, I will use the first method of adding resources for the users_controller.rb. I'll post an update to let you know how everything goes. I'm working on a feature implementation as we speak. Thank you.
Posted in Issues with JQuery AtWho
Hello, I enjoyed your screencast on implementing the @ functionality for user interactions. What I'm trying to figure out is how to handle the index.json.jbuilder when using devise
jQuery ->
$('[data-behavior ="autocomplete"]').atwho(
at: "@",
'data': "/users.json"
)
I cannot access the /users.json url with this approach. I created a separate UsersController for building profiles and displaying them. Otherwise, I'm puzzled on how I would get atWho to play nicely with Devise. I have a friendly_id slug for the username as well.